#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y / 2;
    if (y != 0) x = (x * x) % 1000000007;
  }
  return res;
}
long long ans[2000005], n0[2000005], n1[2000005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t, n, i, j;
  cin >> t;
  n0[1] = 1, n1[1] = 0, ans[0] = ans[1] = ans[2] = 0, ans[3] = 1;
  for (i = 2; i <= 2000000; i++) {
    n0[i] = 2 * n1[i - 1] + n0[i - 1];
    n0[i] = n0[i] % 1000000007;
    n1[i] = n0[i - 1];
    if (i >= 4) {
      ans[i] = n1[i - 1] + ans[i - 3];
      ans[i] = ans[i] % 1000000007;
    }
  }
  while (t--) {
    cin >> n;
    cout << (4 * ans[n]) % 1000000007 << "\n";
  }
  return 0;
}
