CSES - Contiguous numbers

You are given a list containing nn integers. Your task is to pick as many integers from the list as possible. The first number picked can be any number on the list. Each of the other numbers must be exactly one larger than the preceding number. How many numbers can you pick?

The time complexity of the algorithm should be O(nlogn)O(n \log n).

In a file interval.py, implement the function count that returns the maximum number of integers that can be picked as described.

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][10, 4, 8] we can pick only one number, since no two numbers differ by exactly 11. From the list [7,6,1,8][7, 6, 1, 8] we can pick 33 numbers in the order 66, 77 and 88.