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