#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
long long int dp[2000005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int i, j, k, n, t;
  cin >> t;
  dp[3] = 1;
  for (i = 4; i <= 2000000; i++) {
    long long int temp1 =
        (1 + (4 * dp[i - 4]) % mod + (4 * dp[i - 3]) % mod + dp[i - 2] % mod) %
        mod;
    long long int temp2 = ((2 * dp[i - 2]) % mod + dp[i - 1] % mod) % mod;
    dp[i] = max(temp1, temp2);
  }
  while (t--) {
    cin >> n;
    cout << (4 * dp[n]) % mod << endl;
  }
  return 0;
}
