Deals with empty, 1, and 2 entry arrays. Also deals with duplicates in array like [1,1,1,2,3,4,100].