#include <bits/stdc++.h>
using namespace std;
int main() {
  long T, n;
  cin >> T;
  while (T--) {
    cin >> n;
    if (n == 1)
      cout << "0\n";
    else
      cout << n - 2 << endl;
  }
  return 0;
}
