#include <bits/stdc++.h>
using namespace std;
const long long A = 100000000000000LL, N = 228228;
long long i, j, n, m;
long long f(int a) { return max(0, a - 2); }
int main() {
  int test;
  cin >> test;
  while (test--) {
    int n;
    scanf("%d", &n);
    cout << f(n) << "\n";
  }
}
