3. In Chernomorsk, there are $n$ residents. All of them formed a party. Then this party split into two non-intersecting factions, each of which declared itself a party. Each subsequent day, each party formed on the previous day, consisting of at least two members, split into two factions. Factions consisting of at least two people immediately declared themselves parties. No other parties were formed. When the process ended, each resident of Chernomorsk paid a membership fee of 1 ruble to each party they belonged to. What is the maximum amount the total fees could have been?
3. Let $\operatorname{Max}(n)$ be the maximum possible sum of membership fees, $\operatorname{Min}(x)$ be the minimum possible. Let $k$ be the optimal initial division of the Black Sea men into two parties, so that the sum of membership fees would be, say, minimal. Then $\operatorname{Min}(n)=\operatorname{Min}(k)+\operatorname{Min}(n-k)+n$ because within the factions, the Black Sea men divide optimally. Thus, the following equality holds:

$$
\operatorname{Min}(n)=\min _{k}(\operatorname{Min}(k)+\operatorname{Min}(n-k))+n
$$

Similarly, for the problem of the maximum membership fees, the following equality holds:

$$
\operatorname{Max}(n)=\max _{k}(\operatorname{Max}(k)+\operatorname{Max}(n-k))+n
$$

From formula (2), it is easy to verify by direct induction that $\operatorname{Max}(n)=n(n+1) / 2-1$.

The equality for the minimum membership fees is somewhat more complex. Let $n=2^{k}+l ; 0 \leqslant l \leqslant 2^{k}$. Then $\operatorname{Min}(n)=k n+2 l$. This equality is also derived from formula (1) using induction. Accordingly, $\operatorname{Min}(2047)=11 \cdot 2047$.

Remark. One can consider a binary tree associated with the partitioning into parties/factions and note that if there are two hanging vertices whose levels differ by at least 2, then one of them can be moved to the other so that the total sum of membership fees decreases.