#include <bits/stdc++.h>
const long long DIV = 1e9 + 7;
using namespace std;
long long T, n, k;
long long born[2000001], sec1[2000001], sec2[2000001];
long long dp[2000001];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> T;
  born[1] = 1;
  for (int i = 2; i <= 2000000; i++) {
    born[i] = (born[i - 1] + sec1[i - 1] * 2) % DIV;
    sec1[i] = born[i - 1] % DIV;
    sec2[i] = sec1[i - 1] % DIV;
  }
  for (int i = 3; i <= 2000000; i++) {
    dp[i] = (dp[i - 3] + sec2[i] * 4) % DIV;
  }
  while (T--) {
    cin >> n;
    cout << dp[n] << "\n";
  }
  return 0;
}
