\documentclass[UTF8,a4paper]{article}

\usepackage{amsmath,amssymb}
\usepackage{amsthm}
\usepackage{array} 

\begin{document}

\begin{align*}D(X)=&{}\sum\limits_{i=1}^n\left(x_i-E(X)\right)^2p_i\\
=&{}\left(x_1-E(X)\right)^2p_1+\left(x_2-E(X)\right)^2p_2+\cdots+\left(x_n-E(X)\right)^2p_n
\end{align*}

\end{document}


