MAINT: rewrote `check_array_monotonic` following @charris suggestion to
       minimize indexing.