#include <bits/stdc++.h>
using namespace std;
long long dp[2 * 1000000 + 1];
int32_t main() {
  dp[1] = 0;
  dp[2] = 0;
  for (long long i = 3; i <= 2 * 1000000; i++) {
    if (i % 3 == 0)
      dp[i] = (dp[i - 1] + 2 * dp[i - 2] + 1) % 1000000007;
    else
      dp[i] = (dp[i - 1] + 2 * dp[i - 2]) % 1000000007;
  }
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    cout << (dp[n] * 4) % 1000000007 << "\n";
  }
  return 0;
}
