#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
long long int t, n, m, a[2000005] = {0};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int i, j, k, x, y;
  a[3] = a[4] = 4;
  for (i = 5; i < 2000005; i++) {
    a[i] = a[i - 1] + (2 * a[i - 2]);
    if (i % 3 == 0) a[i] += 4;
    a[i] %= mod;
  }
  cin >> t;
  while (t--) {
    cin >> n;
    cout << a[n] << '\n';
  }
  return 0;
}
