#include<cstdio>
#define int long long
using namespace std;
const int mod=1e9+7;
int n;
int fpow(int x,int y){
int ans=1;
while(y){
if(y&1){
ans*=x;
ans%=mod;
}
x*=x;
x%=mod;
y>>=1;
}
return ans;
}
signed main(){
freopen("magic.in","r",stdin);
freopen("magic.out","w",stdout);
scanf("%lld",&n);
int ans=fpow(3,n+1);
ans=((ans-1)%mod+mod)%mod;
ans*=fpow(2,mod-2);
ans%=mod;
printf("%lld",ans);
return 0;
}