#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000000 + 1, mod = 1000000007;
int n;
long long dp[maxn] = {};
int main() {
  int T;
  scanf("%d", &T);
  for (int i = 3; i < maxn; ++i)
    dp[i] = (dp[i - 1] + dp[i - 2] * 2 + (!(i % 3) ? 4 : 0)) % mod;
  while (T--) {
    scanf("%d", &n);
    printf("%d\n", dp[n]);
  }
  return 0;
}
