#include <bits/stdc++.h>
using namespace std;
void onScreen() {
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
}
const int NMAX = 3e6;
const int VMAX = 1e7 + 10;
const int MOD = 1e9 + 7;
int n;
int v[NMAX];
int dp[NMAX];
void read() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> v[i];
}
void solve() {
  dp[1] = dp[2] = 0;
  dp[3] = 4;
  for (int i = 4; i < NMAX; i++) {
    dp[i] = ((dp[i - 2] * 2) % MOD + dp[i - 1]) % MOD;
    if (i % 3 == 0) {
      dp[i] += 4;
      dp[i] %= MOD;
    }
  }
  for (int i = 1; i <= n; i++) cout << dp[v[i]] << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q = 1;
  while (q--) {
    read();
    solve();
  }
  return 0;
}
