#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  cin >> TESTS;
  while (TESTS--) {
    solve();
  }
  return 0;
}
void solve() {
  long long n;
  cin >> n;
  if (n == 1 || n == 2) {
    cout << "0" << endl;
    return;
  } else {
    cout << n - 2 << endl;
    return;
  }
  return;
}
