#include <bits/stdc++.h>
using namespace std;
bool iseven(long long n) {
  if (n % 2 == 0)
    return true;
  else {
    return false;
  }
}
long long power(long long x, unsigned long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
void print(vector<char> a, int n) {
  for (int i = 0; i < n; i += 1) cout << a[i];
}
bool sec(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first == b.first)
    return (a.second < b.second);
  else {
    return (a.first < b.first);
  }
}
vector<long long> v(2000005, -1);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  v[0] = 0;
  v[1] = 0;
  v[2] = 0;
  for (int i = 3; i <= 2000002; i++) {
    if (v[i] == -1) {
      v[i] = (v[i - 1] + (v[i - 2] * 2) % 1000000007 + (i % 3 ? 0 : 1) * 4) %
             1000000007;
    }
  }
  while (t--) {
    long long n;
    cin >> n;
    cout << v[n] << "\n";
  }
  return 0;
}
