#include <bits/stdc++.h>
using namespace std;
long long dp[2000006][3], p3[2000006], T, n;
signed main() {
  dp[1][0] = 0;
  dp[1][1] = 1;
  dp[2][0] = 1;
  dp[2][1] = 1;
  p3[0] = 1;
  for (long long i = 1; i <= 2000005; i++)
    (p3[i] = p3[i - 1] * 3) %= 1000000007;
  for (long long i = 3; i <= 2000005; i++) {
    (dp[i][1] += dp[i - 1][0]) %= 1000000007;
    (dp[i][1] += 2 * dp[i - 2][0]) %= 1000000007;
    (dp[i][1] += 1) %= 1000000007;
    (dp[i][0] += max(dp[i - 1][0], dp[i - 1][1])) %= 1000000007;
    (dp[i][0] += max(dp[i - 2][0], dp[i - 2][1]) * 2) %= 1000000007;
  }
  cin >> T;
  while (T--) {
    cin >> n;
    if (n <= 2)
      cout << 0 << endl;
    else if (n == 3)
      cout << 4 << endl;
    else
      cout << (max(dp[n - 2][0], dp[n - 2][1])) * 4 % 1000000007 << endl;
  }
}
