#include <bits/stdc++.h>
using namespace std;
long long int power_mod(long long int a, long long int x) {
  if (x == 0) return 1;
  long long int y = power_mod(a, x / 2);
  long long int ans = (y * y) % 1000000007;
  if (x % 2) ans = (ans * a) % 1000000007;
  return ans;
}
long long int inv(long long int a) { return power_mod(a, 1000000007 - 2); }
long long int power(long long int a, long long int x) {
  if (x == 0) return 1;
  long long int y = power(a, x / 2);
  long long int ans = (y * y);
  if (x % 2) ans *= a;
  return ans;
}
long long int f[2000001][3] = {};
long long int dp[2000001] = {};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  memset(f, 0, sizeof(f));
  memset(dp, 0, sizeof(dp));
  f[1][0] = 1;
  for (long long int i = 2; i < 2000001; i++) {
    f[i][0] = (f[i - 1][0] + (2ll * f[i - 1][1]) % 1000000007) % 1000000007;
    f[i][1] = (f[i - 1][0]);
    f[i][2] = (f[i - 1][2] + f[i - 1][1]) % 1000000007;
  }
  for (long long int i = 3; i < 2000001; i++) {
    dp[i] = (dp[i - 3] + (f[i][2] - f[i - 1][2] + 1000000007) % 1000000007) %
            1000000007;
  }
  while (t--) {
    long long int n;
    cin >> n;
    cout << (4ll * dp[n]) % 1000000007 << endl;
  }
}
