#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e6 + 10;
const long long MOD = 1e9 + 7;
long long dp[3][MAX];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  dp[0][3] = 4, dp[1][3] = 4, dp[2][3] = 4;
  for (int i = 4; i < MAX; i++) {
    dp[0][i] = (dp[2][i - 1] + 2 * dp[2][i - 2]) % MOD;
    dp[1][i] = (dp[2][i - 2] + 2 * dp[2][i - 3] + 2 * dp[2][i - 3] +
                4 * dp[2][i - 4] + 4) %
               MOD;
    dp[2][i] = max(dp[0][i], dp[1][i]);
  }
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    cout << dp[2][n] << "\n";
  }
  return 0;
}
