#include <bits/stdc++.h>
using namespace std;
int64_t mod = 1e9 + 7;
int64_t spawn[2000003];
int64_t sums[2000003];
void init() {
  spawn[0] = 0;
  spawn[1] = 1;
  sums[0] = 0;
  sums[1] = 0;
  sums[2] = 0;
  for (int i = 0; i < 2000001; ++i) {
    if (i >= 2) spawn[i] = (spawn[i - 1] + 2 * spawn[i - 2]) % mod;
    if (i > 2)
      sums[i] = (sums[i - 3] + spawn[i] * 4LL) % mod;
    else {
      sums[i] = 4LL * spawn[i];
    }
  }
}
void solve(int cnum) {
  int n;
  cin >> n;
  int64_t ans = 0;
  cout << (n > 2 ? sums[n - 2] : 0) << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  init();
  int t;
  int count = 1;
  for (cin >> t; t--; solve(count), count++)
    ;
  return 0;
}
