#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
long long g[2000001];
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  long long pprev, prev = 1, cur = 1;
  g[0] = 0;
  g[1] = 1;
  g[2] = 1;
  for (int i = 3; i < 2000001; i++) {
    pprev = cur;
    cur = (cur + 2 * prev) % INF;
    prev = pprev;
    g[i] = g[i - 3] + cur;
    g[i] %= INF;
  }
  while (t--) {
    int n;
    cin >> n;
    long long ans = (g[n - 2] * 4LL) % INF;
    cout << ans << '\n';
  }
  return 0;
}
