a = int(input()) b = pow(3, a, 10**9+7) if a % 2 == 0: b = b + 3 else: b = b - 3 b = (b * 250000002) % (10**9+7) print(b)