Problem: Find all positive integers $n$
for which there exist non-negative integers $a_1, a_2, \dots, a_n$
such that
\[ \frac{1}{2^{a_1}} + \frac{1}{2^{a_2}} + \dots + \frac{1}{2^{a_n}}
  = \frac{1}{3^{a_1}} + \frac{2}{3^{a_2}} + \dots + \frac{n}{3^{a_n}}
  = 1. \]

\end{enumerate}

Solution: The answer is $n \equiv 1, 2 \pmod 4$.
To see these are necessary,
note that taking the latter equation modulo $2$ gives
\[ 1 = \frac{1}{3^{a_1}} + \frac{2}{3^{a_2}} + \dots + \frac{n}{3^{a_n}}
\equiv 1 + 2 + .. + n \pmod 2. \]

Now we prove these are sufficient.
The following nice construction was posted on AOPS
by the user \texttt{cfheolpiixn}.

\begin{claim*}
  If $n = 2k-1$ works then so does $n = 2k$.
\end{claim*}
\begin{proof}
  Replace
  \[ \frac{k}{3^r} = \frac{k}{3^{r+1}} + \frac{2k}{3^{r+1}}.
    \qquad(\ast) \qedhere \]
\end{proof}

\begin{claim*}
  If $n = 4k+2$ works then so does $n = 4k + 13$.
\end{claim*}
\begin{proof}
  First use the identity
  \[
    \frac{k+2}{3^r} = \frac{k+2}{3^{r+2}}
    + \frac{4k+ 3}{3^{r+3}}
    + \frac{4k+ 5}{3^{r+3}}
    + \frac{4k+ 7}{3^{r+3}}
    + \frac{4k+ 9}{3^{r+3}}
    + \frac{4k+11}{3^{r+3}}
    + \frac{4k+13}{3^{r+3}}
  \]
  to fill in the odd numbers.
  The even numbers can then be instantiated with $(\ast)$ too.
\end{proof}

Thus it suffices to construct base cases
for $n = 1$, $n = 5$, $n = 9$.
They are
\begin{align*}
  1 &= \frac{1}{3^0} \\
  &= \frac{1}{3^2} + \frac{2}{3^2} + \frac{3}{3^2}
    + \frac{4}{3^3} + \frac{5}{3^3} \\
  &= \frac{1}{3^2} + \frac{2}{3^3} + \frac{3}{3^3}
  + \frac{4}{3^3} + \frac{5}{3^3} + \frac{6}{3^4}
  + \frac{7}{3^4} + \frac{8}{3^4} + \frac{9}{3^4}.
\end{align*}