#include <bits/stdc++.h>
using namespace std;
int t, n;
long long q[2000123][2], ans[2000123];
int main() {
  ios_base::sync_with_stdio(0);
  q[1][0] = 1;
  ans[3] = ans[4] = 4;
  for (int i = 2; i < 2000123; ++i) {
    q[i][0] = q[i - 1][0] + q[i - 1][1] * 2LL;
    q[i][1] = q[i - 1][0];
    if (i >= 5) {
      ans[i] = 4LL * (q[i - 1][1]) + ans[i - 3];
    }
    if (ans[i] >= 1000000007LL) ans[i] %= 1000000007LL;
    if (q[i][0] >= 1000000007LL) q[i][0] %= 1000000007LL;
    if (q[i][1] >= 1000000007LL) q[i][1] %= 1000000007LL;
  }
  cin >> t;
  while (t--) {
    cin >> n;
    cout << ans[n] << '\n';
  }
  return 0;
}
