Another variation on the theme; I find that either you add a minus signs in front of each term in the second equation or in front of none. Just one minus sign is incorrect in all respects.
You can instead use words in order to help the reader in understanding what’s going on.
\documentclass{article}
\usepackage{amsmath,booktabs}
\begin{document}
In order to compute $a_n$, subtract the
second equation from the first one:
\begin{equation*}
\begin{gathered}
\begin{alignedat}{2}
\sum_{i=1}^{n}a_i
& = a_1+a_2+\dots+a_{n-2}+a_{n-1}+a_n
&& = \left[\frac{n(n+1)}{2}\right]^4
\\
\sum_{i=1}^{n-1}a_i
& = a_1+a_2+\dots+a_{n-2}+a_{n-1}
&& = \left[\frac{n(n-1)}{2}\right]^4
\end{alignedat}
\\
\midrule
a_n = \left[\frac{n(n+1)}{2}\right]^4
- \left[\frac{n(n-1)}{2}\right]^4
\end{gathered}
\end{equation*}
\end{document}
Note. \dots should be used between alike symbols, in this case +; amsmath will take care of what kind of dots is needed. In case the dots are trailing, use \dotsb (like between binary symbols), \dotsm (like for multiplication), \dotsi (like between integrals), \dotsc (like between punctuation).

A different way to present the same argument.
\documentclass{article}
\usepackage{amsmath,booktabs}
\begin{document}
We have proved that, for every $n$,
\begin{equation*}
\sum_{i=1}^{n}a_i = \left[\frac{n(n+1)}{2}\right]^4.
\end{equation*}
Thus, for $n\ge1$, we can say
\begin{equation*}
\sum_{i=1}^{n-1}a_i = \left[\frac{n(n-1)}{2}\right]^4
\end{equation*}
which has the consequence that
\begin{equation*}
\left[\frac{n(n+1)}{2}\right]^4=
\sum_{i=1}^{n}a_i =
a_n+\sum_{i=1}^{n-1}a_i =
a_n+ \left[\frac{n(n-1)}{2}\right]^4.
\end{equation*}
Hence, by comparing the first and the last terms,
\begin{equation*}
a_n=\left[\frac{n(n+1)}{2}\right]^4-\left[\frac{n(n-1)}{2}\right]^4.
\end{equation*}
\end{document}

(A=B) - (C=D)and it does't make much sense to subtract two equations like this. I think that what you want to write isA-C = B-D = .... – Dec 17 '17 at 07:28