#include <bits/stdc++.h>
using namespace std;
int main() {
  int ttime;
  cin >> ttime;
  for (int ccount = 1; ccount <= ttime; ccount++) {
    int n;
    cin >> n;
    int ans = n - 2;
    if (n == 1) ans = 0;
    cout << ans << endl;
  }
}
