#include <bits/stdc++.h>
using namespace std;
int quick_pow(int a, int b, int MOD) {
  a %= MOD;
  int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % MOD;
    b /= 2;
    a = (a * a) % MOD;
  }
  return res;
}
const int maxn = 100000 + 10;
int main() {
  int i, j, T, n;
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    if (n <= 2) {
      puts("0");
      continue;
    }
    printf("%d\n", n - 2);
  }
  return 0;
}
