CSES - Consecutive integers

You are given a list of integers and the task is to pick as many consecutive integers from the list as possible. The first integer picked can be any integer on the list and each of the following integers picked must be exactly one bigger than the preceding integer. How many integers can you pick?

You may assume that the list contains at most 10^5 integers and that each integer is in the range 1 \dots 10^9. The goal is an algorithm with time complexity O(n) or O(n \log n).

In a file interval.py, implement a function count that returns the maximum number of consecutive integers.

def count(t):
    # TODO

if __name__ == "__main__":
    print(count([1, 1, 1, 1])) # 1
    print(count([10, 4, 8])) # 1
    print(count([7, 6, 1, 8])) # 3
    print(count([1, 2, 1, 2, 1, 2])) # 2
    print(count([987654, 12345678, 987653, 999999, 987655])) # 3

Explanation: From the list [10, 4, 8], we can pick only one integer since no two integers differ by one. From the list [7, 6, 1, 8], we can pick three integers in the order 6, 7, 8.