#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int k, n;
long long dp[2000005];
int main() {
  int test;
  cin >> test;
  dp[0] = dp[1] = 0;
  dp[2] = 4;
  for (int i = 3; i <= 2e6; i++)
    dp[i] = (2 * dp[i - 2] + dp[i - 1] + (i % 3 == 2) * 4) % mod;
  while (test--) {
    cin >> n;
    n--;
    cout << dp[n] << '\n';
  }
}
