N=int(input()) r=0 for i in range(1,N+1): r+=i**((i-1)%3+1) print(r)