#include <bits/stdc++.h>
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const long long inf = 0x3f3f3f3f3f3f3f3f;
const int N = 2e5 + 5;
using namespace std;
int t, n, m, x, y, ans;
int a[N] = {0}, b[N] = {0};
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    printf("%d\n", max(0, n - 2));
  }
  return 0;
}
