print(sum((i + 1) ** (i % 3 + 1) for i in range(int(input()))))