For n = 5 the 5th prime is 11 and the sum of first five primes is 2 + 3 + 5 + 7 + 11 = 28, so a(5) = 5*11 - 28 = 27.
Illustration of a(5) = 27:
Consider a diagram in the first quadrant of the square grid in which the number of cells in the n-th horizontal bar is equal to the n-th prime, as shown below:
. _ _ _ _ _ _ _ _ _ _ _
. 11 |_ _ _ _ _ _ _ _ _ _ _|
. 7 |_ _ _ _ _ _ _|* * * *
. 5 |_ _ _ _ _|* * * * * *
. 3 |_ _ _|* * * * * * * *
. 2 |_ _|* * * * * * * * *
.
a(5) is also the area (or the number of cells, or the number of *'s) under the bar's structure of prime numbers: a(5) = 1 + 4 + 6 + 16 = 27.
(End)
MATHEMATICA
nn = 100; p = Prime[Range[nn]]; Range[nn] p - Accumulate[p] (* T. D. Noe, May 02 2011 *)
PROG
(SageMath) [n*nth_prime(n) - sum(nth_prime(j) for j in range(1, n+1)) for n in range(1, 45)] # Danny Rorabaugh, Apr 18 2015
(PARI) vector(80, n, n*prime(n) - sum(k=1, n, prime(k))) \\ Michel Marcus, Apr 20 2015