Help me in solving CNPIIM problem

My issue

plz give approach

My code

#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
	// your code goes here
	ll t;
	cin>>t;
	while(t--){
	    ll n;
	    cin>>n;
	    ll x=n;
	    ll ans=0;
	 while(n>0){
	     ll i=n-1;
	     ll j=x-i;
	     if(i>0 && j>0){
	         ans++;
	          n--;
	     }
	 }
	 cout<<ans<<endl;
	}
	return 0;
}

Problem Link: CNPIIM Problem - CodeChef

When i is initially set to 0 and n is equal to 1, the code does not enter the if condition, preventing the value of n from being further decremented. In simpler terms, the code continues to run because n remains equal to 1 and is not modified to become 0