#include <bits/stdc++.h>
using namespace std;
const int max_v = 2000000;
const long long mod = 1000000007LL;
long long dp[max_v + 5];
int n;
void solve(void);
void init(void);
int main(void) {
  int t;
  scanf("%d", &t);
  init();
  while (t--) solve();
  return 0;
}
void solve(void) {
  scanf("%d", &n);
  printf("%lld\n", (4LL * dp[n]) % mod);
}
void init(void) {
  dp[3] = 1LL;
  dp[4] = 1LL;
  int i;
  for (i = 5; i <= max_v; i++) {
    dp[i] = (dp[i - 1] + 2LL * dp[i - 2] + ((i % 3) ? 0 : 1LL)) % mod;
  }
}
