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