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