This should be pretty straightforward with only two passes through the data: First compute $$a := \max_i\; a_i,$$ which tells you that, if there are $n$ terms, then $$\sum_i e^{a_i} \le n e^a.$$ Since you presumably don't have $n$ anywhere near as large as even $10^{20}$, you should have no worry about overflowing in the computation of $$\tau := \sum_i e^{a_i-a} \le n$$ in double precision. Thus, compute $\tau$ and then your solution is $e^a \tau$.