#include <bits/stdc++.h>
int main() {
  int t, n[100001];
  scanf("%d", &t);
  for (int i = 0; i < t; i++) scanf("%d", &n[i]);
  for (int i = 0; i < t; i++) {
    if (n[i] < 3)
      printf("0\n");
    else if (n[i] % 2 == 0)
      printf("%d\n", n[i] / 2 - 1);
    else
      printf("%d\n", n[i] / 2);
  }
  return 0;
}
