Help me in solving MISSP problem

My issue

Why give me sample output?

My code

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n;
	int d[n];
	for(int i=0;i<n;i++){
	    cin>>d[i];
	}
	  for(int i=0;i<n;i++){
	    sort(d,d+n);
	    if(d[i]==d[i+1])
	    i=i+2;
	    else if(d[i]!=d[i+1])
	  
	
	cout<<d[i]<<endl;
	  }

}

Learning course: Arrays, Strings & Sorting
Problem Link: Chef and Dolls Practice Problem in - CodeChef

@sanjanalcse202
there is much simpler logic to this problem .
just calculate the xor of the whole array.