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