#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N_MAX = 2e6;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int dp[N_MAX];
  dp[1] = dp[0] = 0;
  dp[2] = 4;
  for (int i = 3; i < N_MAX; i++) {
    dp[i] = dp[i - 1] % MOD + (2 * dp[i - 2]) % MOD + ((i % 3 == 2) ? 4 : 0);
    dp[i] %= MOD;
  }
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    --n;
    cout << dp[n] << '\n';
  }
  return 0;
}
