locations = (lower_bound < a) & (a < upper_bound)
cum = locations.cumsum()
lengths = np.roll(cum, -N) - cum == N
result = lengths.nonzero()[0][0] + 1
Find range of length N in a numpy array where some condition is satisfied