//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod = 1e9+7;
const int maxn = 1000111;
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
ll inv3 = qpow(3, mod-2);
ll fac[maxn], ifac[maxn], inv[maxn];
ll C(int x, int y) {return fac[x]*ifac[y]%mod*ifac[x-y]%mod;}
int main()
{
	inv[1] = 1;
	for (int i=2; i<maxn; i++) inv[i] = mod-inv[mod%i]*(mod/i)%mod;
	fac[0] = 1;
	for (int i=1; i<maxn; i++) fac[i] = fac[i-1]*i%mod;
	ifac[0] = 1;
	for (int i=1; i<maxn; i++) ifac[i] = ifac[i-1]*inv[i]%mod;
	int N;
	cin>>N;
	ll a=1, b=0, ans=0;
	for (int K=1; K<=N; K++)
	{
		int na = (b+b)%mod, nb = (a+b)%mod;
		a = na; b = nb;
		ans = (ans+1ll*b*C(N, K)%mod*inv[N]%mod*inv[K])%mod;
	}
	cout<<ans*qpow(inv3, N)%mod<<endl;
	return 0;
}
