Husk, 14 13 1013 bytes
-1 byte thanks to Dominic van Essen
-3 bytes thanks to Jonathan Allan's trick
►Ofo=▲¹Σπ3◄§-▼▲fo=▲¹Σπ3
Explanation
►Ofo=▲¹Σπ3◄§-▼▲fo=▲¹Σπ3
π3 cartesian product of 3 * input
fo filter by composed function
▲¹ =▲¹Σ max of input
equals sum
◄§ = Σ equals sum
► min by composed binary function
-▼▲ max by
O max - sortedmin