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