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