Find Missing and repeating

My code is work correctly for small numbers.For large numbers like 65500 I am getting errors.
Can anyone explain how to overcome this?

class Solution{
public:
int *findTwoElement(int arr, int n) {
long long xors=0,rep=0;
static int r[3];
sort(arr,arr+n);
long long sum=0;
for(int i=0;i<(n-1);i++)
{
xors=(arr[i]^arr[i+1]);
if(xors==0)
{
rep=arr[i];
r[0]=rep;
}
sum+=(arr[i]);
}
sum+=arr[n-1];
long long no=((n)
(n+1))/2;
long long miss=(no-sum)+rep;
r[1]=miss;

    return r;
}

};