#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const unsigned long long INF = 1e18;
const int N = 2 * 1e6;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  vector<long long> dp(N + 1);
  dp[0] = 0;
  dp[1] = 0;
  dp[2] = 0;
  for (int i = 3; i <= N; i++) {
    dp[i] = (dp[i - 1] % M + (dp[i - 2] * 2) % M) % M;
    if (i % 3 == 0) dp[i] = (dp[i] + 1) % M;
  }
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int ans = (dp[n] * 4) % M;
    cout << ans << "\n";
  }
}
