#include <bits/stdc++.h>
using namespace std;
vector<long long> dp(2000000 + 1);
void prepare() {
  dp[1] = 0;
  dp[0] = 0;
  for (int i = 2; i <= 2000000; i++) {
    dp[i] = dp[i - 1] + 2 * dp[i - 2];
    if (i % 3 == 0) {
      dp[i] += 4;
    }
    dp[i] %= 1000000000 + 7;
  }
}
void solver() {
  long long n;
  cin >> n;
  cout << dp[n];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  prepare();
  cin >> t;
  while (t--) {
    solver();
    cout << endl;
  }
}
