#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while (!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
  cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if (idx > 0)
    cerr << ", ";
  else
    cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss;
  ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
double get_time() { return 1.0 * clock() / CLOCKS_PER_SEC; }
const int MAX = 2E6 + 100;
const int MOD = 1E9 + 7;
int main() {
  vector<long long> dp1(MAX), dp2(MAX);
  dp1[1] = 0, dp1[2] = 0;
  dp2[1] = 0, dp2[2] = 0;
  for (int i = 3; i < MAX; i++) {
    dp1[i] = (4 + 2 * dp2[i - 2] + dp2[i - 1]) % MOD;
    dp2[i] =
        (max(dp1[i - 1], dp2[i - 1]) + 2 * max(dp1[i - 2], dp2[i - 2])) % MOD;
  }
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    cout << max(dp1[n], dp2[n]) << '\n';
  }
}
