#include <bits/stdc++.h>
using namespace std;
using ll = long long;
signed main() {
  ll t;
  cin >> t;
  vector<ll> dp(2000005);
  dp[1] = 0;
  dp[2] = 0;
  dp[3] = 1;
  for (ll i = 4; i <= 2000005; i++) {
    dp[i] = ((2 * dp[i - 2]) % 1000000007 + dp[i - 1] + (i % 3 == 0 ? 1 : 0)) %
            1000000007;
  }
  while (t--) {
    ll n;
    cin >> n;
    cout << (4 * dp[n]) % 1000000007 << "\n";
  }
}
