Following Epicurus I believe pleasures are to be avoided if they result in greater pain, and pain is to be welcomed if it results in greater pleasure.

Michel de Montaigne [Essays II, 37. On the resemblance of children to their fathers]