#include <bits/stdc++.h>
using namespace std;
long long base[2][2] = {{2, 1}, {3, 0}};
long long mtrx[2][2] = {{2, 1}, {3, 0}};
long long ans[2][2] = {{6, 3}, {3, 0}};
void multiply(long long mtrx1[2][2], long long mtrx2[2][2]) {
  long long x =
      (mtrx1[0][0] * mtrx2[0][0] + mtrx1[0][1] * mtrx2[1][0]) % 1000000007LL;
  long long y =
      (mtrx1[0][0] * mtrx2[0][1] + mtrx1[0][1] * mtrx2[1][1]) % 1000000007LL;
  long long z =
      (mtrx1[1][0] * mtrx2[0][0] + mtrx1[1][1] * mtrx2[1][0]) % 1000000007LL;
  long long w =
      (mtrx1[1][0] * mtrx2[0][1] + mtrx1[1][1] * mtrx2[1][1]) % 1000000007LL;
  mtrx1[0][0] = x;
  mtrx1[0][1] = y;
  mtrx1[1][0] = z;
  mtrx1[1][1] = w;
}
void power(long long mtrx[2][2], int n) {
  if (n < 2) return;
  power(mtrx, n / 2);
  multiply(mtrx, mtrx);
  if (n & 1) multiply(mtrx, base);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  if (n == 1)
    cout << 0 << '\n';
  else if (n == 2)
    cout << 3 << '\n';
  else if (n == 3)
    cout << 6 << '\n';
  else {
    power(mtrx, n - 3);
    multiply(ans, mtrx);
    cout << ans[0][0] << '\n';
  }
  return 0;
}
