#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 5;
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
void solve() {
  int ans, n;
  cin >> n;
  ans = n - 2;
  if (ans < 0) ans = 0;
  cout << ans << endl;
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
