#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int a, b, c, d, i, j, n, m, k;
int dp[100001];
int main() {
  scanf("%d", &n);
  dp[0] = 0;
  dp[1] = 0;
  dp[2] = 0;
  dp[3] = 1;
  for (int _n(100000), i(4); i <= _n; i++) {
    dp[i] = max(dp[i - 3] + 1, dp[i - 4] + 2);
    dp[i] = max(dp[i], i - 2);
  }
  for (int _n((n)-1), i(0); i <= _n; i++) {
    scanf("%d", &a);
    printf("%d\n", dp[a]);
  }
}
