#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<long long>;
using vpi = vector<pair<long long, long long>>;
using pi = pair<long long, long long>;
const long long nax = 2e6 + 7;
const long long mod = 1e9 + 7;
const long long inf = numeric_limits<long long>::max() - (long long)9e6;
long long n;
long long dp[nax];
void test() {
  dp[3] = dp[4] = 4;
  dp[5] = 12;
  for (long long i = 6; i < nax; i++) {
    dp[i] = (2 * dp[i - 2]) + dp[i - 1] + (i % 3 == 0) * 4;
    dp[i] %= mod;
  }
  long long T;
  cin >> T;
  while (T--) {
    cin >> n;
    cout << dp[n] << '\n';
  }
}
signed main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  long long T = 1;
  while (T--) {
    test();
    cout << "\n";
  }
  return 0;
}
