#include <bits/stdc++.h>
using namespace std;
long long t, n, s[2000001], f[2000001], m = 1000000007;
void dp() {
  s[1] = 1;
  s[2] = 1;
  f[1] = 1;
  f[2] = 1;
  for (int i = 3; i < 2000001; i++) s[i] = (s[i - 2] * 2 + s[i - 1]) % m;
  for (int i = 3; i < 2000001; i++) f[i] = (f[i - 3] + s[i]) % m;
}
int main() {
  scanf("%d", &t);
  dp();
  while (t--) {
    scanf("%d", &n);
    if (n <= 2)
      printf("0\n");
    else
      printf("%lld\n", (4 * f[n - 2]) % m);
  }
  return 0;
}
