#include <bits/stdc++.h>
using namespace std;
int main() {
  int size;
  cin >> size;
  while (size > 0) {
    int u;
    cin >> u;
    if (u % 2 == 0)
      cout << u / 2 - 1;
    else
      cout << u / 2;
    cout << endl;
    size--;
  }
  return 0;
}
