#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
long long dp[3];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long t;
  cin >> t;
  long long n[t];
  for (long long i = (0); i < (t); i++) cin >> n[i];
  map<long long, long long> ans;
  for (long long i = (0); i < (t); i++) ans[n[i]] = -1;
  for (long long i = (1); i <= (2000000); i++) {
    if (i <= 2) {
      dp[i] = 0;
    } else {
      dp[i % 3] = dp[(i - 1) % 3] + 2 * dp[(i - 2) % 3];
      if (i % 3 == 0) dp[i % 3] += 4;
      dp[i % 3] %= MOD;
    }
    if (ans.find(i) != ans.end()) {
      ans[i] = dp[i % 3];
    }
  }
  for (long long i = (0); i < (t); i++) {
    cout << (ans[n[i]]) << endl;
  }
  return 0;
}
