Repeat and Missing number

You are given a read only array of n integers from 1 to n.

Each integer appears exactly once except A which appears twice and B which is missing.

Return A and B.

Here is the code :
vector Solution::repeatedNumber(const vector &A) {
long long int i,n;
long long int X=0,Y=0;
n=A.size();
vector ans;
vector V(A.size());
for(i=0;i<n;i++){
V[A[i]]++;
}
for(i=0;i<n;i++){
if(V[A[i]]>1)
X=(long long int)A[i];
if(V[A[i]]==0 && i!=0)
Y=(long long int)A[i];
}
ans.push_back(X);
ans.push_back(Y);
return ans;
}

Not giving missing number . This is only function.