#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void run() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  run();
  vector<long long> dp((long long)(3e6), 0);
  dp[3] = 4;
  for (long long i = 4; i < (long long)(3e6); i++) {
    long long temp1 = (2 * dp[i - 2] + dp[i - 1]);
    long long temp2 = 4 + (4 * dp[i - 4] + 4 * dp[i - 3] + dp[i - 2]);
    if (i % 3 == 0) {
      dp[i] = temp2;
    } else {
      dp[i] = temp1;
    }
    dp[i] %= (long long)(1e9 + 7);
  }
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    cout << dp[n] << endl;
  }
  return 0;
}
