#include <bits/stdc++.h>
using namespace std;
string imp = "Impossible\n";
const int N = 2e5 + 5;
int bfstim[N];
long long MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tests;
  tests = 1;
  cin >> tests;
  while (tests--) {
    int n;
    cin >> n;
    if (n > 2) {
      cout << n - 2 << "\n";
    } else
      cout << "0\n";
  }
  return 0;
}
