#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  for (int i = 0; i < T; i++) {
    long long n, m;
    cin >> n;
    if (n == 1 || n == 2) {
      cout << "0" << endl;
    } else {
      if (n % 2 == 1)
        cout << (n / 2) << endl;
      else
        cout << (n / 2) - 1 << endl;
    }
  }
}
