#include <bits/stdc++.h>
using namespace std;
const int_fast64_t modulo = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  using tuple_t = tuple<int_fast64_t, int_fast64_t, int_fast64_t, int_fast64_t>;
  vector<tuple_t> d(2000001);
  get<0>(d[1]) = 1;
  for (size_t i = 2; i < d.size(); ++i) {
    get<0>(d[i]) = (get<0>(d[i - 1]) + 2 * get<1>(d[i - 1])) % modulo;
    get<1>(d[i]) = get<0>(d[i - 1]);
    get<2>(d[i]) = (get<1>(d[i - 1]) + get<2>(d[i])) % modulo;
    get<3>(d[i]) = get<1>(d[i - 1]);
    if (i >= 3) {
      get<3>(d[i]) += get<3>(d[i - 3]);
      get<3>(d[i]) %= modulo;
    }
  }
  size_t T;
  cin >> T;
  for (size_t t = 0; t < T; ++t) {
    int_fast64_t n;
    cin >> n;
    cout << 4 * get<3>(d[n]) % modulo << endl;
  }
  return 0;
}
