#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
const double PI = atan(1.0) * 4;
const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, -1, 0, 1};
const long long INF = (long long)2e18 + 50;
const int maximum = numeric_limits<int>::min();
const int minimum = numeric_limits<int>::max();
constexpr int N = 2e6, P = 1000000007;
int a[N + 1], b[N + 1];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 1; i <= N; ++i) {
    a[i] = (2ll * a[i - 2] + a[i - 1]) % P;
    if (b[i - 1] && b[i - 2]) {
      a[i] = (a[i] + 1) % P;
    } else {
      b[i] = 1;
    }
  }
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    cout << 4ll * a[n] % P << "\n";
  }
  return 0;
}
