max_negative = 0 for i in xrange(len(offsets)): start, size = offsets[i] if start >= 0: break max_negative = min(max_negative, start) offsets = offsets[i:]