Inconsistent constraints for this problem

The constraints for this problem seem to be inconsistent with the sample case and topic.

  1. The array can have elements < 0 as in test case, but the constraint shows 0<a[i]<1000.

Yes…there is a mistake there. The array elements can be negative. I have checked with the test cases.