#include <bits/stdc++.h>
const int mod = int(1e9 + 7);
const int MN = int(2e6 + 7);
using namespace std;
int main() {
  int t;
  cin >> t;
  vector<long long int> dp(MN, 0);
  dp[1] = 0;
  dp[2] = 0;
  dp[3] = 4;
  for (int i = 4; i <= MN; i++) {
    long long w = (2 * dp[i - 2]) + (dp[i - 1]) + (i % 3 == 0 ? 4 : 0);
    dp[i] = w % mod;
  }
  while (t--) {
    int n;
    cin >> n;
    cout << dp[n] << endl;
  }
}
