#include <bits/stdc++.h>
using namespace std;
int const N = 2e6 + 5, M = 20 + 5, MOD = 1e9 + 7, OO = 0x3f3f3f3f;
int t, n;
long long ans[N];
int main() {
  scanf("%d", &t);
  ans[1] = 0;
  ans[2] = 4;
  for (int i = 3; i <= 2e6; i++)
    ans[i] = (2 * ans[i - 2] + ans[i - 1] + (i % 3 == 2) * 4) % MOD;
  while (t--) {
    scanf("%d", &n);
    printf("%I64d\n", ans[--n]);
  }
  return 0;
}
