#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
const long long MOD = 2e9 + 7;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    if (n % 2)
      cout << (n - 1) / 2;
    else
      cout << n / 2 - 1;
    cout << '\n';
  }
  return 0;
}
