#include <bits/stdc++.h>
using namespace std;
long long Mod = 1000000007;
long long Power3[10000010];
int main() {
  Power3[0] = 1;
  for (int i = 1; i < 10000010; i++)
    Power3[i] = (3 * (Power3[i - 1] % Mod)) % Mod;
  long long n;
  cin >> n;
  long long Answer = 0;
  long long z = 1;
  for (long long i = n - 1; i > 0; i--) {
    Answer =
        ((Answer % Mod) + ((Mod + z * (Power3[i] % Mod)) % Mod) % Mod) % Mod;
    z = -z;
  }
  cout << Answer;
}
