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