#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t = 1;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    if (n <= 2) {
      cout << 0 << endl;
      continue;
    }
    if (n % 2 == 0) {
      long long v = (n / 2) - 1;
      cout << v << endl;
      continue;
    }
    cout << n / 2 << endl;
    continue;
  }
}
