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