\documentclass{jarticle}
\usepackage{amsmath}

\begin{document}

\begin{center}
{\tabcolsep = 1mm
\begin{tabular}{rrrrrrrrrrrrr}
$ S$&$=$&$1$&$+$&$r$&$+$&$r^2$&$+$&$\cdots$&$+$&$r^n$& &\\
$rS$&$=$&$ $&$ $&$r$&$+$&$r^2$&$+$&$\cdots$&$+$&$r^n$&$+$&$r^{n+1}$ \\
\hline
$(1-r)S$&$=$&$1$&$ $&$ $&$ $&$   $&$ $&$      $&$ $&$   $&$-$&$r^{n+1}$
\end{tabular}
}
\end{center}

$$
\begin{array}{crrrrrrrrrrrr}
  S     & = & 1 & + & r & + & r^2 & + & \cdots & + & r^n &   &          \\
 rS     & = &   &   & r & + & r^2 & + & \cdots & + & r^n & + & r^{n+1}  \\
\hline
 (1-r)S & = & 1 &   &   &   &     &   &        &   &     & - & r^{n+1} 
\end{array}
$$

$$
\begin{array}{rrrrrrrrrrrrr}
  S     & = & 1 & + & r & + & r^2 & + & \cdots & + & r^n &   &          \\
 rS     & = &   &   & r & + & r^2 & + & \cdots & + & r^n & + & r^{n+1}  \\
\hline
 (1-r)S & = & 1 &   &   &   &     &   &        &   &     & - & r^{n+1} 
\end{array}
$$

\end{document}
