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