#include <bits/stdc++.h>
using namespace std;
int main() {
  int testcases;
  long candies;
  std::cin >> testcases;
  for (int i = 0; i < testcases; i++) {
    std::cin >> candies;
    if (candies <= 1) {
      std::cout << "0" << endl;
    } else if (candies % 2 == 0) {
      std::cout << (candies / 2) - 1 << endl;
    } else if (candies % 2 != 0) {
      std::cout << (candies - 1) / 2 << endl;
    }
  }
}
