mod = 10 ** 9 + 7 n = int(input()) dp = [0] * (n + 1) dp[0] = 1 for i in range(1, n + 1): dp[i] = (pow(3, i - 1, mod) - dp[i - 1]) % mod print(dp[-1])