#include <bits/stdc++.h>
using namespace std;
const int N = 1e9 + 7;
long long int n, chetkiypacan = 1, nechetkiyepacan;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    chetkiypacan = (chetkiypacan * 3) % N;
  }
  if (n % 2 == 0) {
    chetkiypacan += 3;
  } else {
    chetkiypacan -= 3;
  }
  chetkiypacan *= 250000002;
  cout << chetkiypacan % N;
  return 0;
}
