UNIQUE NUMBER 2

I have written same code as told in the videos and is still giving output as 0 0 and sometimes 0 1 . Code is :
#include
using namespace std;

int main() {

int n, a[100006],res;
cin>>n;
for (int i=0;i<n;i++)
{
	cin>>a[i];
	res=res^a[i];
}
int temp=res;
int pos=0;
while((temp & 1) != 0)
{
	pos++;
	temp = temp >> 1;
}
int mask = (1 << pos);
int x=0;
int y=0;
for(int i=0;i<n;++i)
{
	if((a[i] & mask)>0)
	{
		x^=a[i];
	}
}
y=res^x;
cout<<min(x,y)<<" "<<max(x,y);

return 0;

}

@aanandraj460 your mask should be 1 >> pos