#include <bits/stdc++.h>
int main(int argc, char const *argv[]) {
  long long int t, i, n, j, a, b, c;
  scanf("%lld", &t);
  for (i = 1; i <= t; i++) {
    scanf("%lld", &n);
    if (n == 1 || n == 2) {
      c = 0;
    } else {
      c = (n - 1) / 2;
    }
    printf("%lld\n", c);
  }
  return 0;
}
