I have a finite set $P = \{1, 5, 3, 6, 4, ..., p_n\}$ of size $N$ and average $A$.

I want to find the most efficient way to maximize the following function:

$$ f(x, y) = \frac{1}{(1+e^{-6(x-2)})(1+e^{-6(y-2)})(1+e^{-0.1x-0.3y+1.5})} $$

where:

- $S \subsetneq P$;
- $x = |S|$;
- $y = \frac{min(S)}{A}$.

I really have no idea where to start other than sorting $P$. I'm looking for optimal time complexity or at least something considerably better than bruteforcing.

The conflicting extreme ideas are:

Taking a subset with $|S| = 1$ where the only element is $s = max(P)$. This will maximize the $y$ part but minimize the $x$ part.

Taking a subset with $|S| = N-1$ where the element that's excluded is $s = min(P)$. This will maximize the $x$ part but minimize the $y$ part.