def missing_elements(L, count):
    missing = chain.from_iterable(list(range(x + 1, y)) for x, y in window(L) if 
        y - x > 1)
return list(islice(missing, 0, count))
Efficient way to find missing elements in an integer sequence