#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v, vo;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  for (int i = 0; i < n; i++) {
    int tt = 0;
    if (v[i] % 2 == 0)
      tt = v[i] / 2 - 1;
    else
      tt = v[i] / 2;
    if (v[i] > 2)
      vo.push_back(tt);
    else
      vo.push_back(0);
  }
  for (int x : vo) cout << x << endl;
  return 0;
}
