Example 5 Given that $A$ and $B$ are finite sets composed of different positive real numbers, $n$ ($n>1$) is a given positive integer, and both $A$ and $B$ have at least $n$ elements. If the sum of any $n$ different real numbers in $A$ belongs to $B$, and the product of any $n$ different real numbers in $B$ belongs to $A$, find the maximum number of elements in $A$ and $B$.
(52nd Belarusian Mathematical Olympiad (Final B Category))
Assume set $A$ contains $m$ elements, denoted as $a_{1}, a_{2}, \cdots, a_{m}$, and satisfies
$0n)$.
Let $S=a_{1}+a_{2}+\cdots+a_{n+1}$,
$P=\left(S-a_{1}\right)\left(S-a_{2}\right) \cdots\left(S-a_{n+1}\right)$.
Then $S-a_{k} \in B(k=1,2, \cdots, n+1)$.
Set $t_{i}=\frac{P}{S-a_{i}}(i=1,2, \cdots, n+1)$,
$$
\begin{array}{l} 
t_{k}=\frac{P\left(S-a_{1}-a_{n+1}+a_{k}\right)}{\left(S-a_{n}\right)\left(S-a_{n+1}\right)}(k=n+2, \\
n+3, \cdots, m), \\
t_{m+1}=\frac{P\left(S-a_{1}-a_{n}+a_{m}\right)}{\left(S-a_{n}\right)\left(S-a_{n+1}\right)} .
\end{array}
$$

Then $t_{i}(i=1,2, \cdots, m+1)$ are all the product of $n$ different elements in $B$.
Thus, $t_{i} \in A(i=1,2, \cdots, m+1)$, and satisfy
$$
t_{1}<t_{2}<\cdots<t_{n+1}<t_{n+2}<\cdots<t_{m}<t_{m+1} \text {, }
$$

which contradicts the fact that $A$ has $m$ elements.
Therefore, $A$ has at most $n$ elements.
Thus, it is known that $A$ has $n$ elements.
If $b_{1}, b_{2}, \cdots, b_{n+1} \in B$, and satisfy
$$
0<b_{1}<b_{2}<\cdots<b_{n+1} \text {, }
$$

then $\frac{M}{b_{k}} \in A(k=1,2, \cdots, n+1)$, where $M=$ $b_{1} b_{2} \cdots b_{n+1}$, and satisfies $0<\frac{M}{b_{n+1}}<\frac{M}{b_{n}}<\cdots<\frac{M}{b_{1}}$, which is a contradiction.
Hence, both $A$ and $B$ have $n$ elements.
Therefore, the maximum value is $2 n$.
Take $A=\{1,2, \cdots, n\}$,
$$
B=\left\{1,2, \cdots, n-2, \frac{n(n+1)}{2}, \frac{2(n-1)}{(n+1)!}\right\},
$$

it can be seen that $2 n$ is achievable.