```
public class Solution {
public int missingNumber(int[] nums) {
Arrays.sort(nums);
if(nums[0] > 0) return nums[0]-1;
int index = 0;
while(index < nums.length-1){
if(nums[index+1] - nums[index] ==1){
index++;
}
else{
return nums[index] + 1;
}
}
return nums[index] + 1;
}
}
```