2008 AIME II Problem 4

There exist r unique nonnegative integers n_{1}>n_{2}>\cdots>n_{r} and r unique integers a_{k}(1 \leq k \leq r) with each a_{k} either 1 or -1 such that

a_{1} 3^{n_{1}}+a_{2} 3^{n_{2}}+\cdots+a_{r} 3^{n_{r}}=2008

Find n_{1}+n_{2}+\cdots+n_{r}.