#include <bits/stdc++.h>
using namespace std;
int dX[8] = {1, 0, 0, -1, -1, -1, 1, 1};
int dY[8] = {0, 1, -1, 0, -1, 1, -1, 1};
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};
long double EPS = 1e-9;
long long int MOD = 1e9 + 7;
const int N = 1e3 + 10, M = 1e4, OO = 0x3f3f3f3f;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    long long int n, a;
    cin >> n;
    if (n < 3) {
      cout << 0 << endl;
      continue;
    }
    a = n / 2;
    ++a;
    cout << n - a << endl;
  }
  return 0;
}
