If $\displaystyle S(n) = \sum\limits_{p\leq n} p$, (sum of primes not exceeding $n$),
then by Abel's summation formula, we may write:
$$S(n) = n\pi(n) - \sum\limits_{j=2}^{n-1} \pi(j)$$
So, using the estimate $\displaystyle \pi (x) = \frac{x}{\log x} + O\left( \frac{x}{\log ^2 x} \right)$,
$\begin{align}S(n) &= \frac{n^2}{\log n} + O\left(\frac{n^2}{\log^2 n}\right) - \sum\limits_{j=2}^{n-1} \frac{j}{\log j}\\&= \frac{n^2}{\log n} + O\left(\frac{n^2}{\log^2 n}\right) - \left(\int_{2}^{n} \frac{x}{\log x}\,dx + O\left(\frac{n}{\log n}\right)\right) \,\textrm{(Since, $\frac{x}{\log x}$ is monotone)} \\ &= \frac{n^2}{\log n} - \left(\left.\frac{x^2}{2\log x}\right\vert_{2}^{n} + \int_2^{n} \frac{x}{2\log^2 x}\,dx\right)+ O\left(\frac{n^2}{\log^2 n}\right) \\ &= \frac{n^2}{\log n} - \left(\frac{n^2}{2\log n} + O\left(\frac{n^2}{\log^2 n}\right)\right)+ O\left(\frac{n^2}{\log^2 n}\right)\\ &= \frac{n^2}{2\log n} + O\left(\frac{n^2}{\log^2 n}\right)\end{align}$