#include <bits/stdc++.h>
#pragma GCC optimize "03"
using namespace std;
const long long int N = 2e6 + 5;
const long long int mod = 1e9 + 7;
const long long int inf = 1e9 + 9;
long long int f[N];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  f[3] = 4;
  for (long long int i = 4; i < N; i++) {
    long long int a = (f[i - 1] + 2 * f[i - 2]) % mod;
    long long int b = (f[i - 2] + 4 * f[i - 3] + 4 * f[i - 4] + 4) % mod;
    f[i] = max(a, b);
  }
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    cout << f[n] << '\n';
  }
  return 0;
}
