#include <bits/stdc++.h>
using namespace std;
template <typename T>
void arrout(T arr[], int len) {
  for (int i = 0; i <= len; ++i) cout << arr[i] << " ";
  cout << endl;
}
int OK = 1;
const int INF = 0x3f3f3f3f;
int main() {
  int T;
  scanf("%d", &T);
  int n, v;
  while (T--) {
    scanf("%d", &v);
    if (v <= 2)
      puts("0");
    else
      printf("%d\n", v - 2);
  }
  return 0;
}
