#include <bits/stdc++.h>
using namespace std;
const int maxn = (2 * 1e6) + 10;
const int mod = 1e9 + 7;
long long dp[maxn], i, t, n;
void solve() {
  dp[0] = 0;
  dp[1] = 0;
  dp[2] = 0;
  for (int i = 3; i < maxn; i++) {
    dp[i] = (dp[i - 1] + 2 * dp[i - 2]) % mod;
    if (i % 3 == 0) {
      dp[i] += 4;
      dp[i] %= mod;
    }
  }
}
int main() {
  solve();
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    cout << dp[n] << endl;
  }
}
