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