#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
using namespace std;
const int mo=1000000007;
const int N=1000005;
int n,k,ans,f[N][2];
int fac[N],inv[N],Inv[N];
int C(int x,int y){
	return 1ll*fac[x]*inv[y]%mo*inv[x-y]%mo;
}
int main(){
	scanf("%d",&n);
	fac[0]=inv[0]=Inv[0]=Inv[1]=1;
	For(i,2,N-1) Inv[i]=1ll*Inv[mo%i]*(mo-mo/i)%mo;
	For(i,1,N-1){
		fac[i]=1ll*fac[i-1]*i%mo;
		inv[i]=1ll*inv[i-1]*Inv[i]%mo;
	}
	f[0][0]=1;
	For(i,1,n){
		f[i][1]=(2ll*f[i-1][0]+f[i-1][1])%mo;
		f[i][0]=f[i-1][1];
	}
	For(i,1,n){
		int ways=1ll*f[i][1]*Inv[2]%mo*C(n,i)%mo;
		ans=(ans+1ll*ways*Inv[i])%mo; 
	}
	For(i,1,n) ans=1ll*ans*Inv[3]%mo;
	ans=1ll*ans*Inv[n]%mo;
	printf("%d\n",ans);
} 