#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void ran() { srand(chrono::steady_clock::now().time_since_epoch().count()); }
long long get_rand() {
  long long a = rand();
  long long b = rand();
  return a * (RAND_MAX + 1ll) + b;
}
long long MOD = 1000 * 1000 * 1000 + 7;
const long long n = 2000000;
long long dp[n + 1];
signed main() {
  ran();
  fast();
  dp[0] = 0;
  dp[1] = 0;
  dp[2] = 0;
  dp[3] = 4;
  dp[4] = 4;
  for (long long i = 5; i <= n; i++) {
    dp[i] = 1 * dp[i - 1] + 2 * dp[i - 2];
    if (i % 3 == 0) dp[i] += 4;
    dp[i] %= MOD;
  }
  long long t;
  cin >> t;
  while (t--) {
    long long x;
    cin >> x;
    cout << dp[x] << endl;
  }
}
