mod = 10 ** 9 + 7 one_third = pow(3, mod - 2, mod) n = int(input()) assert(2 <= n <= 10 ** 9) print(n * (n + 1) * one_third % mod)