class Integer def mod_pow(n, mod) x = self res = 1 while n > 0 res = res * x % mod if n[0] == 1 x = x * x % mod n >>= 1 end res end def mod_inverse(mod) mod_pow(mod - 2, mod) end end N = gets.to_i MOD = 10 ** 9 + 7 pp N * (N + 1) * 3.mod_inverse(MOD) % MOD