#include <bits/stdc++.h>
using namespace std;
long long n, m, k, flag;
long long p[2000009], a[2000009];
void init() {
  p[3] = p[4] = 1;
  a[3] = 1;
  a[4] = 0;
  for (int i = 5; i < 2000009; i++) {
    if (a[i - 1] == 0 && a[i - 2] == 0) {
      a[i] = 1;
      p[i] = (2 * p[i - 2] + p[i - 1] + 1) % 1000000007;
    } else
      p[i] = (2 * p[i - 2] + p[i - 1]) % 1000000007;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  init();
  cin >> k;
  while (k--) {
    cin >> n;
    printf("%lld\n", 4 * p[n] % 1000000007);
  }
  return 0;
}
