#include <bits/stdc++.h>
using namespace std;
template <typename T>
int size(const T& c) {
  return int(c.size());
}
template <typename T>
T abs(T x) {
  return x < 0 ? -x : x;
}
template <typename T>
T sqr(T x) {
  return x * x;
}
template <typename T>
bool remin(T& x, T y) {
  if (x <= y) return false;
  x = y;
  return true;
}
template <typename T>
bool remax(T& x, T y) {
  if (x >= y) return false;
  x = y;
  return true;
}
const int maxn = 20;
int n;
bool adj[maxn][maxn];
int deg[maxn];
int res;
void check() {
  int d[maxn];
  for (int i(0), _n(n); i < _n; ++i) d[i] = deg[i];
  bool del[maxn] = {};
  for (int x(1), _b(n - 1); x <= _b; ++x) {
    static vector<int> v;
    v.clear();
    for (int i(0), _n(n); i < _n; ++i)
      if (!del[i] && d[i] == x) {
        del[i] = true;
        v.push_back(i);
      }
    for (int i(0), _n(n); i < _n; ++i)
      if (!del[i])
        for (int j(0), _n(size(v)); j < _n; ++j)
          if (adj[i][v[j]]) --d[i];
  }
  int cnt = count(del, del + n, false);
  remax(res, cnt);
}
void rec(int i, int j) {
  if (i == n) {
    for (int i(0), _n(n - 1); i < _n; ++i) assert(deg[i] <= deg[i + 1]);
    assert(deg[0] > 0);
    check();
  } else if (j >= n) {
    if (deg[i] == 0 || i > 0 && deg[i] < deg[i - 1]) return;
    rec(i + 1, i + 2);
  } else {
    adj[i][j] = adj[j][i] = false;
    rec(i, j + 1);
    adj[i][j] = adj[j][i] = true;
    ++deg[i];
    ++deg[j];
    rec(i, j + 1);
    --deg[i];
    --deg[j];
  }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t-- > 0) {
    int n;
    scanf("%d", &n);
    printf("%d\n", max(n - 2, 0));
  }
}
