#include <bits/stdc++.h>
using namespace std;
const long long N = 2e6 + 7;
const long long mod = 1e9 + 7;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  vector<long long> dp(N);
  dp[0] = 0;
  dp[1] = 0;
  dp[2] = 0;
  dp[3] = 4;
  for (long long i = 4; i < N; i++) {
    long long val = dp[i - 1];
    val += 2 * dp[i - 2];
    val += (i % 3 != 0 ? 0 : 4);
    val %= mod;
    dp[i] = val;
  }
  long long tt = 1;
  cin >> tt;
  while (tt--) {
    long long n;
    cin >> n;
    cout << dp[n] % mod << endl;
  }
  return 0;
}
