##################### mod=10**9+7 def mul(a,b): n=len(a) m=len(b[0]) res=[[0]*m for i in range(n)] for i in range(n): for j in range(m): for k in range(len(a[0])): res[i][j]+=a[i][k]*b[k][j] res[i][j]%=mod return res def add(a,b): res=[[0]*len(a[0]) for i in range(len(a))] for i in range(len(a)): for j in range(len(a[0])): res[i][j]=(a[i][j]+b[i][j])%mod return res def mpow(a,n): N = len(a) if n == 0: res = [[0] * N for i in range(N)] for i in range(N): res[i][i] = 1 return res if n==1:return a res=mpow(a,n//2) res=mul(res,res) if n%2==1: res=mul(res,a) return res def det(A): a=[] for line in A: a.append(line[:]) n=len(a) f=1 for now in range(n): ind=-1 for i in range(now,n): a[i][now]%=mod if a[i][now]>0: ind=i break if ind==-1:return 0 a[now],a[ind]=a[ind],a[now] if now!=ind:f*=-1 f=f*a[now][now]%mod inv=pow(a[now][now],mod-2,mod) for j in range(now,n): a[now][j]*=inv a[now][j]%=mod for i in range(now+1,n): x=a[i][now] for j in range(now,n): a[i][j]-=a[now][j]*x a[i][j]%=mod for i in range(n): f*=a[i][i] f%=mod return f def minv(A): n=len(A) if det(A)==0:return -1 a=[] for i in range(n): e=[0]*n e[i]=1 a.append(A[i][:]+e) for now in range(n): ind = -1 for i in range(now, n): a[i][now] %= mod if a[i][now] > 0: ind = i break if ind == -1: return -1 a[now], a[ind] = a[ind], a[now] inv = pow(a[now][now], mod - 2, mod) for j in range(now, 2*n): a[now][j] *= inv a[now][j] %= mod for i in range(now + 1, n): x = a[i][now] for j in range(now, 2*n): a[i][j] -= a[now][j] * x a[i][j] %= mod for now in range(n-1,-1,-1): for i in range(now-1,-1,-1): x=a[i][now] for j in range(2*n): a[i][j]-=a[now][j]*x a[i][j]%=mod res=[] for l in a:res.append(l[n:]) return res ####################### n=int(input()) a=[[0]*4 for i in range(4)] a[1][0]+=1 a[0][1]+=1 a[3][1]+=1 a[0][2]+=1 a[2][3]+=1 a=mpow(a,n-1) ans=[[0] for i in range(4)] ans[1][0]=1 ans=mul(a,ans) res=0 if n%2==0: res=ans[0][0] else: res=ans[0][0]+ans[1][0]+ans[2][0] print(res%mod)