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