#include <bits/stdc++.h>
long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
using namespace std;
const long long maxn = 2e6 + 7;
const double eps = 1e-10;
const long long mod = 1e9 + 7;
struct Node {
  long long data;
  bool f;
};
vector<Node> node(maxn);
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  node[1].data = 0;
  node[1].f = 1;
  node[2].data = 0;
  node[2].f = 1;
  for (long long i = 3; i <= 2e6; i++) {
    node[i].data = (node[i - 1].data + 2 * node[i - 2].data % mod) % mod;
    if (node[i - 1].f && node[i - 2].f) {
      node[i].data = (node[i].data + 4) % mod;
      node[i].f = 0;
    } else {
      node[i].f = 1;
    }
  }
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    cout << node[n].data << "\n";
  }
}
