#include <bits/stdc++.h>
using namespace std;
const int N = 2000010, M = 1010, mod = 1e9 + 7;
int T, n;
int f[N];
int main() {
  f[1] = f[2] = 0;
  for (int i = 3; i < N; i++)
    f[i] = (long long)((2LL * f[i - 2] + f[i - 1]) % mod + 4LL * (i % 3 == 0)) %
           mod;
  cin >> T;
  while (T--) {
    cin >> n;
    cout << f[n] << '\n';
  }
  return 0;
}
