// c++ program for the above approach
#include <bits/stdc++.h>
using namespace std;
void solve(int arr[], int n){
int x=0,y=0;
int xor1=0;
for(int i=0;i<n;i++){
xor1=arr[i]^xor1;
}
for(int i=0;i<n;i++){
xor1= xor1^i;
}
int set_bit_xor = xor1& ~(xor1-1);
for(int i=0;i<n;i++){
if (arr[i] & set_bit_xor)
{ x ^= arr[i]; }
else
{ y ^= arr[i]; }
// Decide whether (i+1) is in first set
// or second
if ((i+1) & set_bit_xor)
{ x ^= (i + 1); }
else
{ y ^= (i + 1); }
}
cout << "Missing and Repeating (In any order) "
<< x << " " << y;
}
int main() {
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
solve(arr,n);
return 0;
}
Ly8gYysrIHByb2dyYW0gZm9yIHRoZSBhYm92ZSBhcHByb2FjaAojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnZvaWQgc29sdmUoaW50IGFycltdLCBpbnQgbil7CglpbnQgeD0wLHk9MDsKCWludCB4b3IxPTA7Cglmb3IoaW50IGk9MDtpPG47aSsrKXsKCQl4b3IxPWFycltpXV54b3IxOwoJfQoJZm9yKGludCBpPTA7aTxuO2krKyl7CgkJeG9yMT0geG9yMV5pOwoJfQoJaW50IHNldF9iaXRfeG9yID0geG9yMSYgfih4b3IxLTEpOwoJCglmb3IoaW50IGk9MDtpPG47aSsrKXsKCQlpZiAoYXJyW2ldICYgc2V0X2JpdF94b3IpICAKCQl7IHggXj0gYXJyW2ldOyB9ICAKICAgICAgICBlbHNlICAgICAgICAgICAgICAKICAgICAgICB7IHkgXj0gYXJyW2ldOyB9IAogICAgICAKICAgICAgICAvLyBEZWNpZGUgd2hldGhlciAoaSsxKSBpcyBpbiBmaXJzdCBzZXQgCiAgICAgICAgLy8gb3Igc2Vjb25kCiAgICAgICAgaWYgKChpKzEpICYgc2V0X2JpdF94b3IpICAKICAgICAgICB7IHggXj0gKGkgKyAxKTsgfQogICAgICAgIGVsc2UgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgeyB5IF49IChpICsgMSk7IH0KCX0KCWNvdXQgPDwgIk1pc3NpbmcgYW5kIFJlcGVhdGluZyAoSW4gYW55IG9yZGVyKSAiIAogICAgICAgICA8PCB4IDw8ICIgIiA8PCB5Owp9CgppbnQgbWFpbigpIHsKCWludCBuOwoJY2luPj5uOwoJaW50IGFycltuXTsKCWZvcihpbnQgaT0wO2k8bjtpKyspCgljaW4+PmFycltpXTsKCXNvbHZlKGFycixuKTsKCXJldHVybiAwOwp9