Test case not passing

I’ve written this code but it’s not passing one test case. Where’s the mistake? Please let me know!

#include
using namespace std;
int main() {

int n;
int a[n],res=0;
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
res = res^a[i];
}
int rescopy = res;

int p=0;

while((res&1)!= 1){
res = res>>1;
p++;
}

int mask = 1<<p;
int x=0,y;
for(int i=0;i<n;i++){
if(a[i]&mask>0){
x = x^a[i];
}
}
y = x^rescopy;
cout<<min(x,y)<<" "<<max(x,y);
}

@payal_05 small mistake
corrected and commented


dont forget to hit like and mark resolved if cleared :smiley: