#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long inf = 1e18;
long long m_inf = INT_MIN;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  std::cout.unsetf(std::ios::fixed);
  std::cout.precision(9);
  long long t = 1;
  cin >> t;
  vector<long long> ans(2e6 + 1);
  long long sz = 2e6 + 1;
  ans[1] = ans[2] = 0;
  for (long long i = 3; i < sz; i++) {
    ans[i] = (ans[i - 1] + 2 * ans[i - 2]) % mod;
    ;
    if (i % 3 == 0) ans[i] = (ans[i] + 4) % mod;
  }
  while (t--) {
    long long n;
    cin >> n;
    cout << ans[n] << '\n';
  }
}
