#include <bits/stdc++.h>
using namespace std;
set<pair<long long, long long> > st;
string s;
long long n, m, v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long ans = n - 2;
    if (n == 1)
      cout << 0 << endl;
    else
      cout << ans << endl;
  }
}
