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