#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const ll p=1000000007ll;
const int p1=1000000006,N=1000005;
ll dp[N][3],inv[N],ifa[N];
inline ll add(ll a){return a<p?a:a-p;}
inline ll expo(ll a,int b=1000000005){
	ll c=1ll;
	while(b){
		if(b&1)c=c*a%p;
		b>>=1; a=a*a%p;
	}
	return c;
}
int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,i;ll fn=1ll,fc=1ll,s=0ll;
    scanf("%d",&n);
    REP(i,2,n)fn=fn*i%p;
	ifa[n]=expo(fn*n%p);
	fn=fn*expo(3ll,p1-n)%p;
	per(i,n,1)ifa[i-1]=ifa[i]*i%p;
	rep(i,1,n){
		inv[i]=fc*ifa[i]%p;
		fc=fc*i%p;
	}
	dp[0][1]=1ll;
	REP(i,0,n){
		dp[i+1][0]=add(dp[i][1]+dp[i][2]);
		dp[i+1][1]=add(dp[i][2]+dp[i][0]);
		dp[i+1][2]=add(dp[i][0]+dp[i][1]);
	}
	//printf("9fn=%lld\n",9ll*fn%p);
	//rep(i,1,n)printf("dp=%lld prob=fn/%lld\n",dp[i][0],expo(inv[i]*(ifa[i]*ifa[n-i]%p)%p));
	rep(i,1,n)s=(s+(dp[i][0]*inv[i]%p)*(ifa[i]*ifa[n-i]%p))%p;
	printf("%lld",fn*s%p);
    return 0;
}
### Prompt

Generate a Cpp solution to the following problem:

We have a round pizza. Snuke wants to eat one third of it, or something as close as possible to that.

He decides to cut this pizza as follows.

First, he divides the pizza into N pieces by making N cuts with a knife. The knife can make a cut along the segment connecting the center of the pizza and some point on the circumference of the pizza. However, he is very poor at handling knives, so the cuts are made at uniformly random angles, independent from each other.

Then, he chooses one or more consecutive pieces so that the total is as close as possible to one third of the pizza, and eat them. (Let the total be x of the pizza. He chooses consecutive pieces so that |x - 1/3| is minimized.)

Find the expected value of |x - 1/3|. It can be shown that this value is rational, and we ask you to print it modulo 10^9 + 7, as described in Notes.

Constraints

* 2 \leq N \leq 10^6

Input

Input is given from Standard Input in the following format:


N


Output

Print the expected value of |x - 1/3| modulo 10^9 + 7, as described in Notes.

Examples

Input

2


Output

138888890


Input

3


Output

179012347


Input

10


Output

954859137


Input

1000000


Output

44679646

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const ll p=1000000007ll;
const int p1=1000000006,N=1000005;
ll dp[N][3],inv[N],ifa[N];
inline ll add(ll a){return a<p?a:a-p;}
inline ll expo(ll a,int b=1000000005){
	ll c=1ll;
	while(b){
		if(b&1)c=c*a%p;
		b>>=1; a=a*a%p;
	}
	return c;
}
int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,i;ll fn=1ll,fc=1ll,s=0ll;
    scanf("%d",&n);
    REP(i,2,n)fn=fn*i%p;
	ifa[n]=expo(fn*n%p);
	fn=fn*expo(3ll,p1-n)%p;
	per(i,n,1)ifa[i-1]=ifa[i]*i%p;
	rep(i,1,n){
		inv[i]=fc*ifa[i]%p;
		fc=fc*i%p;
	}
	dp[0][1]=1ll;
	REP(i,0,n){
		dp[i+1][0]=add(dp[i][1]+dp[i][2]);
		dp[i+1][1]=add(dp[i][2]+dp[i][0]);
		dp[i+1][2]=add(dp[i][0]+dp[i][1]);
	}
	//printf("9fn=%lld\n",9ll*fn%p);
	//rep(i,1,n)printf("dp=%lld prob=fn/%lld\n",dp[i][0],expo(inv[i]*(ifa[i]*ifa[n-i]%p)%p));
	rep(i,1,n)s=(s+(dp[i][0]*inv[i]%p)*(ifa[i]*ifa[n-i]%p))%p;
	printf("%lld",fn*s%p);
    return 0;
}
```