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