#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10, mod = 1e9 + 7;
long long dp[N][2];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 3; i <= N; i++) {
    int ans1, ans2;
    ans1 = (dp[i - 1][1] + 4 + (2 * dp[i - 2][1]) % mod) % mod;
    ans2 = (dp[i - 1][0] + (2 * dp[i - 2][0]) % mod) % mod;
    dp[i][0] = max(ans1, ans2);
    dp[i][1] = ans2;
  }
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    cout << dp[n][0] << endl;
  }
}
