#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
map<pair<int, int>, int> M;
map<int, int> ID;
vector<pair<pair<int, int>, int> > v;
int n;
bool cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  return a.first.first > b.first.first;
}
int ban[maxn], bid = 0;
int main() {
  int T;
  cin >> T;
  while (T--) {
    int a;
    scanf("%d", &a);
    printf("%d\n", max(0, a - 2));
  }
  return 0;
}
