#include <bits/stdc++.h>
using namespace std;
long long dp[2123456][2];
int main() {
  long long t, n;
  cin >> t;
  dp[2][0] = 0;
  dp[2][1] = 0;
  dp[3][0] = 4;
  dp[3][1] = 0;
  for (int i = 4; i <= 2000000; i++) {
    dp[i][0] = (4 + 2 * dp[i - 2][1] + dp[i - 1][1]) % 1000000007;
    if (i % 3 == 0) {
      dp[i][1] = (2 * dp[i - 2][0] + dp[i - 1][1]) % 1000000007;
    }
    if (i % 3 == 1) {
      dp[i][1] = (2 * dp[i - 2][1] + dp[i - 1][0]) % 1000000007;
    }
    if (i % 3 == 2) {
      dp[i][1] = (2 * dp[i - 2][0] + dp[i - 1][1]) % 1000000007;
    }
  }
  while (t--) {
    cin >> n;
    if (n % 3 == 0) {
      cout << dp[n][0] << endl;
    } else {
      cout << dp[n][1] << endl;
    }
  }
  return 0;
}
