#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int M = 1e9 + 7;
ll n, ans;
ll qpow(ll x, ll k){
ll res = 1;
while(k){
if(k & 1) res = ((res % M) * (x % M)) % M;
k >>= 1;
x = ((x % M) * (x % M)) % M;
}
return res;
}
int main(){
freopen("magic.in", "r", stdin);
freopen("magic.out", "w", stdout);
cin >> n;
ans = (((qpow(3, n + 1) - 1) % M) * (qpow(2, M - 2) % M)) % M;
cout<<ans % M<<endl;
return 0;
}