'''
Name:		Problem 28

Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:

21 22 23 24 25
20  7  8  9 10
19  6  1  2 11
18  5  4  3 12
17 16 15 14 13

It can be verified that the sum of the numbers on the diagonals is 101.

What is the sum of the numbers on the diagonals in a 1001 by 1001 spiral formed in the same way?



5x5 has 5^2 terms
Sum of diagonals: 101

7x7 has 7^2 terms:
43 44 45 46 47 48 49
42 21 22 23 24 25 26
41 20  7  8  9 10 27
40 19  6  1  2 11 28
39 18  5  4  3 12 29
38 17 16 15 14 13 30
37 36 35 34 33 32 31
Sum of diagonals: 
261

nxn has n^2 terms

used terms:
n=1
1
n=3
1, 3, 5, 7, 9
n=5
1, 3, 5, 7, 9, 13, 17, 21, 25
n=7
1, 3, 5, 7, 9, 13, 17, 21, 25, 31, 37, 43, 49

c=last digit of previous circle

total=sum from n=1 to n= 1001 for 4*(n-2)^2+(n-1)+2(n-1)+3(n-1)+4(n-1)=4*(n-2)^2+10*(n-1)=4n^2-16n+16+10n-10=4n^2-6n+6
Sum n(1->101) 4n^2-6n+6


'''
sum=1
for n in range(3, 1002, 2):
	sum = sum + 4*(pow(n, 2)) - (6 * n) + 6
print(sum)