#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
long long dp[2000005], t, n;
;
int main() {
  dp[0] = dp[1] = 0;
  dp[2] = 4;
  for (int i = 3; i < 2000005; ++i) {
    long long a = dp[i - 1];
    a += 2 * dp[i - 2] + (i % 3 == 2) * 4;
    a %= mod;
    dp[i] = a;
  }
  scanf("%lld", &t);
  while (t--) {
    scanf("%lld", &n);
    printf("%lld\n", dp[n - 1] % mod);
  }
}
