int firstMissingPositive(int A[], int n) {

int HIT = -199928;

for(int i=0;i<n; i++){

int t = A[i];

while(t!=HIT && t>=1 && t<=n){

int temp = A[t-1];

A[t-1] = HIT;

t = temp;

}

}

for(int i=0; i<n; i++){

if(A[i]!=HIT){

return i+1;

}

}

return n+1;

}