#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
ll myp(ll a, ll b) {
  if (b == 0) {
    return 1;
  }
  if (b % 2 == 1) {
    return a * myp(a, b - 1) % mod;
  }
  ll c = myp(a, b / 2);
  return c * c % mod;
}
ll inv(ll a) { return myp(a, mod - 2); }
int main() {
  int n;
  cin >> n;
  ll ans = myp(3, n) * inv(4) % mod;
  if (n % 2 == 1) {
    ans = (ans - 3 * inv(4) + mod) % mod;
  } else {
    ans = (ans + 3 * inv(4)) % mod;
  }
  cout << ans << endl;
  return 0;
}
