#include <bits/stdc++.h>
using namespace std;
long long t, n, dp[2100000][2], ans;
int main() {
  cin >> t;
  for (int i = 3; i < 2000000 + 1; i++) {
    dp[i][1] = dp[i - 1][0] + 2 * dp[i - 2][0] + 1;
    dp[i][0] =
        max(dp[i - 1][0], dp[i - 1][1]) + 2 * max(dp[i - 2][0], dp[i - 2][1]);
    dp[i][1] = (dp[i][1] % 1000000007 + 1000000007) % 1000000007;
    dp[i][0] = (dp[i][0] % 1000000007 + 1000000007) % 1000000007;
  }
  while (t--) {
    cin >> n;
    cout << (4 * max(dp[n][1], dp[n][0]) % 1000000007 + 1000000007) % 1000000007
         << "\n";
  }
}
