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