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