#include <bits/stdc++.h>
using namespace std;
int n, t;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    if (n <= 2) {
      cout << 0 << endl;
      continue;
    } else {
      int x;
      x = n / 2;
      if (n % 2 == 0) x--;
      cout << x << endl;
    }
  }
}
