We show that if A ⊆ {1, . . . , N } does not contain any nontrivial solutions to the equationwhere c > 0 is some absolute constant. In view of Behrend's construction, this bound is of the right shape: the exponent 1/7 cannot be replaced by any constant larger than 1/2. We also establish a related result, which says that sumsets A + A + A contain long arithmetic progressions if A ⊆ {1, . . . , N }, or high-dimensional affine subspaces if A ⊆ F n q , even if A has density of the shape above.