#include <bits/stdc++.h>
long long int powerMod(int, int, int);
int main() {
  int n;
  scanf("%d", &n);
  long long int arr[n + 1];
  if (n == 1) {
    printf("0");
  } else if (n == 2) {
    printf("3");
  } else if (n == 3) {
    printf("6");
  } else if (n == 4) {
    printf("21");
  } else {
    arr[1] = 0;
    arr[2] = 3;
    arr[3] = 6;
    arr[4] = 21;
    for (int i = 5; i <= n; i++) {
      if (i % 2 == 1) {
        arr[i] = ((arr[i - 1] * 3) % 1000000007 - 3) % 1000000007;
      } else {
        arr[i] = ((arr[i - 1] * 3) % 1000000007 + 3) % 1000000007;
      }
    }
    printf("%lld", arr[n]);
  }
  return 0;
}
long long int powerMod(int a, int n, int m) {
  long long int result = 1;
  while (n > 0) {
    if (n & 1) result = (result * a) % m;
    a *= a;
    n >>= 1;
  }
  return result;
}
