#include <bits/stdc++.h>
using namespace std;
const long long module = 1e9 + 7;
const long int full = 2e6 + 5;
long long f[full];
long long b[full];
void solve() {}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  f[1] = f[2] = 0;
  f[3] = f[4] = 1;
  b[1] = b[2] = 0;
  b[3] = b[4] = 1;
  for (int i = 5; i <= 2000000; i++) {
    b[i] = b[i - 1] + 2 * b[i - 2] % module;
    f[i] = b[i] + f[i - 3] % module;
  }
  int t, x;
  cin >> t;
  for (; t--;) {
    cin >> x;
    cout << f[x] * 4 % module << endl;
  }
  return 0;
}
