#include <bits/stdc++.h>
long long mod = 1000000007;
void normalize(long long &a) { a = (a + mod) % mod; }
long long modmul(long long a, long long b) {
  a = a % mod;
  b = b % mod;
  normalize(a);
  normalize(b);
  return (a * b) % mod;
}
long long modadd(long long a, long long b) {
  a = a % mod;
  b = b % mod;
  normalize(a);
  normalize(b);
  return (a + b) % mod;
}
long long modsub(long long a, long long b) {
  a = a % mod;
  b = b % mod;
  normalize(a);
  normalize(b);
  return (a - b + mod) % mod;
}
long long me(long long x, long long n) {
  x %= mod;
  if (n == 0) return 1;
  long long u = me(x, n / 2) % mod;
  u = (u * u) % mod;
  if (n % 2) u = (u * x) % mod;
  return u;
}
long long ipow(long long a, long long b) {
  long long c = 1;
  while (b--) c *= a;
  return c;
}
long long logb(long long a, long long b) {
  long long ans = 0;
  while (a >= b) {
    a /= b;
    ans++;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
bool isprime(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  if (n == 1) return false;
  return true;
}
using namespace std;
long long a[200005];
void solve() {
  long long ar[20001][2];
  long long a, b, c;
  a = 0;
  b = 0;
  c = 0;
  for (long long i = 3; i < 2000001; i++) {
    a = b;
    b = c;
    c = (b + (2 * a) % 1000000007) % 1000000007;
    if (i % 3 == 0) c = (c + 4) % 1000000007;
    if (i % 100 == 0) {
      ar[i / 100][0] = c;
      ar[i / 100][1] = b;
    }
  }
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    ;
    long long index = n / 100;
    long long cc = ar[index][0];
    long long bb = ar[index][1];
    long long aa;
    for (long long j = index * 100 + 1; j <= n; j++) {
      aa = bb;
      bb = cc;
      cc = (bb + (2 * aa) % 1000000007) % 1000000007;
      if (j % 3 == 0) cc = (cc + 4) % 1000000007;
    }
    cout << cc << "\n";
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}
