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