#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n;
  cin >> t;
  int *arr = new int[t];
  for (int i = 0; i < t; i++) {
    cin >> n;
    if (n > 1)
      cout << n - 2 << endl;
    else
      cout << 0 << endl;
  }
  return 0;
}
