#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int oo = INT_MAX;
const ll OO = 1e18;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
ll GCD(ll a, ll b) { return ((!b) ? a : GCD(b, a % b)); }
ll LCM(ll a, ll b) { return a / (GCD(a, b)) * b; }
double distance(double x1, double y1, double x2, double y2) {
  return hypot(fabs(x1 - x2), fabs(y1 - y2));
}
int comp_double(double a, double b) {
  if (fabs(a - b) <= EPS) return 0;
  return (a < b) ? -1 : 1;
}
int main() {
  ios_base::sync_with_stdio(0), ios::sync_with_stdio(0), cin.tie(0),
      cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    if (n == 1) {
      cout << 0 << endl;
    } else {
      cout << n - 2 << endl;
    }
  }
}
