#include <bits/stdc++.h>
using namespace std;
mt19937 rd(chrono ::steady_clock ::now().time_since_epoch().count());
long long Rand(long long l, long long h) { return l + rd() % (h - l + 1); }
template <typename T>
inline void read(T &x) {
  register char c;
  bool sign = 0;
  for (c = getchar(); !isdigit(c); c = getchar())
    if (c == '-') sign = !sign;
  x = c - '0';
  for (c = getchar(); isdigit(c); c = getchar()) x = x * 10 + c - '0';
  if (sign) x = -x;
}
template <typename T>
inline bool mini(T &x, T y) {
  if (x > y)
    x = y;
  else
    return 0;
  return 1;
}
template <typename T>
inline bool maxi(T &x, T y) {
  if (x < y)
    x = y;
  else
    return 0;
  return 1;
}
template <typename T>
inline void _abs(T &x) {
  if (x < 0) x = -x;
  return;
}
const int N = 2e6 + 6;
const long long mod = 1e9 + 7;
long long n;
long long f[N], g[N];
long long res[N];
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  f[1] = 1;
  f[2] = 1;
  for (int i = 3; i < N; ++i) {
    f[i] = (f[i - 1] + f[i - 2] * 2 % mod) % mod;
    g[i] = f[i - 2];
    res[i] = (res[i - 3] + g[i] * 4 % mod) % mod;
  }
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    cout << res[n] << '\n';
  }
  return 0;
}
