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