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