#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    if (n <= 2)
      cout << 0 << "\n";
    else {
      if (n % 2 == 0) {
        long long a = n / 2 + 1, b = n - a;
        cout << b << "\n";
      } else {
        long long a = n / 2 + 1, b = n - a;
        cout << b << "\n";
      }
    }
  }
  return 0;
}
