#include <bits/stdc++.h>
using namespace std;
int T = 0;
long long int dp[2000003];
long long int sol[2000003];
int main() {
  dp[0] = 0;
  dp[1] = 1;
  dp[2] = 1;
  dp[3] = 3;
  sol[3] = 4;
  for (long long int i = 4; i < 2000001; i++) {
    dp[i] = ((dp[i - 2] * 2 % 1000000007) + dp[i - 1]) % 1000000007;
    sol[i] = (sol[i - 3] + (dp[i - 2] * 4) % 1000000007) % 1000000007;
  }
  cin >> T;
  while (T--) {
    int N;
    cin >> N;
    cout << sol[N] << "\n";
  }
}
