First you use Ostrogradsky theorem
#intintØvecA*vec(dS) = intintint vecgrad*Øvec(A)dV #
#intintint vecgrad O/*vec(A)dV= intintint vecgrad*O/vec(A)dV-intintintO/vecgrad*vecAdV#
and then you use the formula
#vecgrad*O/ vec(A) = O/ vecgrad*vec(A) + vecgradO/*vecA #
and then it's trivial
#intintint vecgrad O/*vec(A)dV= intintint O/ vecgrad*vec(A)dv + intintintvecgradO/*vecAdV-intintintO/vecgrad*vecAdV#
you can memorize the formula #vecgrad*O/ vec(A) = O/ vecgrad*vec(A) + vecgradO/*vecA # easily because it's like when you derivate two function
#(u*v)' = u'v + uv'#
except here you have one vector