#include <bits/stdc++.h>
using namespace std;
long long nwd(long long a, long long b) { return !b ? a : nwd(b, a % b); }
inline int CEIL(int a, int b) { return a % b ? a / b + 1 : a / b; }
template <class T>
inline T sqr(const T& a) {
  return a * a;
}
vector<string> parse(string s) {
  string a;
  vector<string> wyn;
  for (int i = 0; i < ((int)s.size()); i++)
    if (s[i] != ' ')
      a += s[i];
    else if (!a.empty()) {
      wyn.push_back(a);
      a = "";
    }
  if (!a.empty()) wyn.push_back(a);
  return wyn;
}
int toi(char ch) { return int(ch) - int('0'); }
int chg(char ch) { return int(ch) - int('a'); }
int los(int m) { return (int)((double)m * (rand() / (RAND_MAX + 1.0))); }
int main() {
  int t, n;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    printf("%d\n", max(n - 2, 0));
  }
  return 0;
}
