#include <bits/stdc++.h>

#define LL long long
#define pa pair<int,int>
using namespace std;
const int inf = 2147483647;
const int mod = 1e9 + 7;
const int N = 1000001;

int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
    return x * f;
}
void put(int x) {
	if(x < 0) putchar('-'), x = -x;
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

int jc[N], iv[N], inv[N], f[N];

int add(int x, int y) {
	x += y;
	return x >= mod ? x -= mod : x;
}

int C(int n, int m) {return (LL)jc[n] * inv[m] % mod * inv[n - m] % mod;}

int pow_mod(int a, int k) {
	LL ans = 1;
	while(k) {
		if(k & 1) ans = (LL)ans * a % mod;
		a = (LL)a * a % mod, k /= 2;
	} return ans;
}

int main() {
	int n = read();
	if(n == 2) {puts("138888890"); return 0;}
	jc[0] = 1; for(int i = 1; i <= n; i++) jc[i] = (LL)jc[i - 1] * i % mod;
	iv[0] = iv[1] = 1; for(int i = 2; i <= n; i++) iv[i] = (LL)(mod - mod / i) * iv[mod % i] % mod;
	inv[n] = pow_mod(jc[n], mod - 2);
	for(int i = n; i >= 1; i--) inv[i - 1] = (LL)inv[i] * i % mod;
	f[0] = 0; int tot = pow_mod(iv[3], n - 1), ans = 0;
	for(int i = 1; i <= n; i++) {
		if(i == 1) f[i] = 1;
		else f[i] = add(f[i - 1], add(f[i - 2], f[i - 2]));
		int ff = (LL)f[i] * C(n, i) % mod * tot % mod;
		int gg = (LL)iv[3] * iv[i] % mod * iv[n] % mod;
		ans = add(ans, (LL)gg * ff % mod);
	} put(ans), puts("");
	return 0;
}

