N = gets.to_i M = 10**9 + 7 def mod_pow(x, n, m) res = 1 while n > 0 do if n & 1 != 0 then res = res * x % m end x = x * x % m n >>= 1 end res end a = mod_pow(3, N-1, M) b = N % 2 == 0 ? 1 : -1 c = (a + b) * mod_pow(4, M-2, M) % M d = (c * 3) % M puts d