#include <bits/stdc++.h>
using namespace std;
using pii = pair<long long, long long>;
const long long INF = 1e18;
template <class A, class B>
ostream& operator<<(ostream& os, const pair<A, B> p) {
  return os << "(" << p.first << "," << p.second << ")";
}
void dprint(string s) { cout << "\n"; }
template <class T, class... U>
void dprint(string s, T t, U... u) {
  long long w = s.find(',');
  cout << "[" << s.substr(0, w) << ": " << t << "] ";
  dprint(s.substr(w + 1, (long long)s.size() - w), u...);
}
const long long N = 2000005;
const long long mod = 1e9 + 7;
long long arr[N], sum[N] = {};
void precompute() {
  arr[0] = 0, arr[1] = 1, arr[2] = 1;
  for (long long i = 3; i < N; i++)
    arr[i] = arr[i - 1] + 2 * arr[i - 2], arr[i] %= mod;
  sum[0] = 0, sum[1] = 0, sum[2] = 0;
  for (long long i = 3; i < N; i++) {
    sum[i] += arr[i - 2];
    sum[i] += sum[i - 3];
    sum[i] %= mod;
  }
}
void solve() {
  long long n;
  cin >> n;
  long long ans = (4 * sum[n]) % mod;
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long T;
  cin >> T;
  precompute();
  for (long long tc = 1; tc <= T; tc++) {
    solve();
  }
  return 0;
}
