Consent must also be given. If both of these statements aren't evaluated to true, the action is immoral.
By the equation, all forms of imprisonment (consent a definite false) is immoral. As well as the death penalty, and killing, even in self-defense.
There's also cases where consent is impossible to obtain. Children (by law, they cannot give consent). If you claim this is ambiguous, then a KKK activist indoctrinating his children to hate blacks is completely moral (it is a gain for him, and in his view, a gain for his child and humanity since blacks and jews aren't human anyway).
The equation does not take into account the difference between gain of society and personal gain. Quite often, these two are at odds. Which is more important?
Let's take a bunch of comatose people. They can't give consent, so it is ambiguous. Let's kill all of them. Hey, they're all sucking more resources and are a net loss. So, getting rid of them is moral?
Frankly, there are things you do, even at a loss, that are moral. In fact, selflessness and the willingness to take a loss is a hallmark of many admirable actions.