#include <bits/stdc++.h>
using namespace std;
long long int him(long long int a, long long int n) {
  long long int ans = 1;
  while (n) {
    if (n % 2 != 0) {
      ans = ((ans) * (a));
    }
    a = ((a) * (a));
    n = n / 2;
  }
  return ans;
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    if (n == 1 || n == 2)
      cout << 0 << endl;
    else
      cout << n - 2 << endl;
  }
}
