#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long dp[2000006];
void init() {
  dp[1] = 0, dp[2] = 0, dp[3] = 1;
  for (int i = 4; i < 2000006; i++) {
    if (i % 3 == 0) {
      dp[i] = (2 * dp[i - 2] + dp[i - 1] + 1) % mod;
    } else
      dp[i] = (2 * dp[i - 2] + dp[i - 1]) % mod;
  }
}
int main() {
  init();
  int t, n;
  scanf("%d", &t);
  for (int i = 1; i <= t; i++) {
    scanf("%d", &n);
    cout << 4 * dp[n] % mod << endl;
  }
}
