#include <bits/stdc++.h>
using namespace std;
int ar[2000005];
char ch[2000005];
long long re[2000005];
int n, m, k, ii;
long long add(long long a, long long b) {
  return (a + b) >= 1000000007 ? a + b - 1000000007 : a + b;
}
long long mul(long long a, long long b) { return (a * b) % 1000000007; }
void solve() {
  scanf("%d", &n);
  printf("%lld\n", (re[n] * 4) % 1000000007);
}
int main() {
  int t = 1;
  re[3] = 1;
  for (int i = 4; i <= 2000005 - 3; i++) {
    re[i] = add(mul(2, re[i - 2]), re[i - 1]) + (i % 3 == 0);
  }
  scanf("%d", &t);
  while (t--) solve();
  return 0;
}
