N = int(input()) mod = 10 ** 9 + 7 inv = pow(3, mod - 2, mod) print(N * (N + 1) * inv %mod)