#include <bits/stdc++.h>
using namespace std;
const int Mod = 1e9 + 7;
long long f[2000010];
long long sum[2000010];
void init() {
  for (int i = 3; i <= 2e6; i++) {
    f[i] = (2 * f[i - 2] + f[i - 1] + (i % 3 == 0)) % Mod;
  }
}
void solve() {
  int n;
  scanf("%d", &n);
  printf("%lld\n", f[n] * 4 % Mod);
}
int main() {
  init();
  int T;
  scanf("%d", &T);
  while (T--) solve();
  return 0;
}
