#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
const long long int INF = 1e18;
const long long int N = 2e6 + 20;
vector<long long int> g[N];
vector<long long int> vis(N);
vector<long long int> ans(N);
void pre() {
  ans[3] = 4;
  for (long long int i = 4; i < N; i++) {
    ans[i] = (ans[i - 1] + 2 * ans[i - 2]) % MOD;
    if (i % 3 == 0) {
      ans[i] += 4;
      ans[i] %= MOD;
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  pre();
  long long int tc;
  cin >> tc;
  while (tc--) {
    long long int n;
    cin >> n;
    cout << ans[n] << '\n';
  }
}
