#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007, N = 2e6 + 5;
pair<long long, long long> dp[N];
void solve() {
  long long n;
  cin >> n;
  cout << dp[n].first << '\n';
}
int32_t main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  dp[0].first = dp[1].first = dp[2].first = 0;
  dp[3].first = 4;
  dp[0].second = dp[1].second = dp[2].second = 0;
  dp[3].second = 1;
  for (long long i = (long long)4; i < N; i++) {
    dp[i].first = (2 * dp[i - 2].first + dp[i - 1].first) % MOD;
    dp[i].second = ((2 * dp[i - 2].second + dp[i - 1].second) > 0 ? 0 : 1);
    if (dp[i].second == 1) dp[i].first += 4;
  }
  long long t = 1;
  cin >> t;
  while (t--) solve();
}
