Find wether the elements of an array are consecutives in O(n) time and O(1) extra space