#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long N = 1e5 + 7;
long long pref[300000];
bool vis[1000];
int freq[100000];
bool isPowerOR(long long n) {
  bool flag = false;
  if (n > 0) {
    while (n % 2 == 0) {
      n /= 2;
    }
    if (n == 1) flag = true;
  }
  if (n == 0 || n != 1) {
    flag = false;
  }
  if (flag)
    return true;
  else
    return false;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long x;
    long long n;
    cin >> n;
    if (n % 2 == 0) {
      x = (n / 2) - 1;
    } else {
      x = (n / 2);
    }
    if (x < 0)
      cout << 0 << endl;
    else
      cout << x << endl;
  }
}
