#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    if (n == 1 || n == 2)
      cout << "0\n";
    else
      cout << n - 2 << "\n";
  }
  return 0;
}
