#include <bits/stdc++.h>
using namespace std;
long long mod(long long n, long long a) {
  string num = to_string(n);
  long long res = 0;
  for (auto i = 0; i < num.length(); i++) {
    res = (res * 10 + (long long)num[i] - '0') % a;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long tc;
  cin >> tc;
  while (tc--) {
    long long n;
    cin >> n;
    if (n < 3)
      cout << 0 << "\n";
    else {
      if (n % 2 == 0)
        cout << n / 2 - 1 << "\n";
      else
        cout << n / 2 << "\n";
    }
  }
  return 0;
}
