#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e6 + 2;
const int MOD = 1e9 + 7;
long long int dp[MAXN];
void init() {
  dp[1] = dp[2] = 0;
  dp[3] = dp[4] = 4;
  dp[5] = 12;
  dp[6] = 24;
  dp[7] = 48;
  for (int i = 8; i <= 2e6; ++i) {
    if (i % 3 == 0) {
      dp[i] = ((dp[i - 1] + dp[i - 2] * 2 + 4) % MOD + MOD) % MOD;
    } else if (i % 3 == 1) {
      dp[i] = (dp[i - 1] + dp[i - 2] * 2) % MOD;
    } else {
      dp[i] = (dp[i - 1] + dp[i - 2] * 2) % MOD;
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  init();
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    cout << dp[n] << endl;
  }
  return 0;
}
