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