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