#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
const double PI = atan(1.0) * 4;
const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, -1, 0, 1};
const long long INF = (long long)2e18 + 50;
const int maximum = numeric_limits<int>::min();
const int minimum = numeric_limits<int>::max();
long long dp[2000050];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (long long i = 3; i <= 2e6; i++)
    dp[i] = (dp[i - 1] + dp[i - 2] * 2 + (i % 3 == 0) * 4) % 1000000007;
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    cout << dp[n] << "\n";
  }
  return 0;
}
