Sort them first, and then judge whether there are even numbers one by one. Note that the for loop needs i+=2.
#include<bits/stdc++.h> using namespace std; int n,a[10000010]; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); sort(a+1,a+n+1); for(int i=1;i<=n;i+=2){ if(a[i]!=a[i+1]){ cout<<a[i]; return 0; } } return 0; }