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