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