I wrote a quick function that shows you how you can extract these arithmetic sequences from an array. I used range objects to represent them in the end, but you can just as well replace them with slice objects if you prefer. Anyway note that this only works if all sequences have a length of at least two, otherwise it is not possible to uniquely determine what values belong to what sequence. (Any two values trivially form an arithmetic sequence!)
Also note that this works for arbitrary (also negative) step sizes!
import numpy as np
def rangify(s):
# get start and end point of each arithmetic sequence
limits_bool = np.concatenate([[True], np.diff(s, 2) != 0, [True]])
# get limits of the arithmetic sequences
limits_int = s[limits_bool].reshape(-1, 2)
# second value in each arithmetic sequence
second = s[np.nonzero(limits_bool)[0][0::2] + 1]
# compute step size by subtracting first
step = second - limits_int[:, 0]
# use range objects to represent these arithmetic sequences
return [range(start, stop+step, step) for (start, stop), step in zip(limits_int, step)]
s = np.array([0, 1, 2, 3, 4, 5, 6, 502, 503, 504, 505, 506, 507, 508, 26, 24, 22, 20])
print(rangify(s))
print(np.concatenate([list(x) for x in rangify(s)]))
sor [[0,9],[502,511]]?