#include <bits/stdc++.h>
using namespace std;
int t, n;
const int M = 1e9 + 7;
long long N = 2000005;
long long dp[2000005];
void solve() {
  dp[0] = 0;
  dp[1] = 0;
  dp[2] = 0;
  for (int i = 3; i < N; i++) {
    dp[i] = (2 * dp[i - 2] + dp[i - 1]) % M;
    if (i % 3 == 0) dp[i] = (dp[i] + 4) % M;
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solve();
  cin >> t;
  while (t--) {
    cin >> n;
    cout << dp[n] << endl;
  }
}
