#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  if (n == 1 || n == 2) {
    cout << "0\n";
    return;
  }
  if (n & 1) {
    cout << n / 2 << endl;
  } else
    cout << n / 2 - 1 << endl;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long TESTS = 1;
  cin >> TESTS;
  while (TESTS--) {
    solve();
  }
  return 0;
}
