#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 3e5, M = N;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    if (n == 1 || n == 2) {
      cout << 0 << "\n";
    } else if (n % 2 == 0) {
      cout << (n / 2) - 1 << "\n";
    } else {
      cout << (n / 2) << "\n";
    }
  }
  return 0;
}
