search in almost sorted array & find the first repeating element