#include <bits/stdc++.h>
using namespace std;
long long MAX = 2e6;
long long MOD = 1e9 + 7;
long long LEVEL[2000010];
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  LEVEL[1] = 0;
  LEVEL[2] = 0;
  LEVEL[3] = 4;
  for (int i = 4; i <= MAX; i++) {
    if (i % 3)
      LEVEL[i] = (LEVEL[i - 1] + 2 * LEVEL[i - 2]) % MOD;
    else
      LEVEL[i] = (LEVEL[i - 1] + 2 * LEVEL[i - 2] + 4) % MOD;
  }
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    cout << LEVEL[n] % MOD << endl;
  }
}
