#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 22 17:07:27 2025

@author: vincentleprince
"""

t =  [2 , 3 , 10 , 4 , 5 , 6 , 7 , 1 , 11 , 12 ,  13 , 0 , 9 , 14 , 15]  

def nombreCons(t,i):
    n=len(t)
    l=1
    while i+l<n and t[i+l]==t[i+l-1]+1:
        l+=1
    return l


print(nombreCons(t,0))
print(nombreCons(t,1))
print(nombreCons(t,3))
print(nombreCons(t,13))

def nombreConsMax(t):
    n=len(t)
    m=nombreCons(t,0)
    for i in range(1,n):
        if nombreCons(t,i)>m:
            m=nombreCons(t,i)
    return m

print(nombreConsMax(t))


def nombreConsMax2(t):
    n=len(t)
    i=0
    l=1 # On maintient : t[i,i+l] est une liste d'entiers consécutifs
    m=1 # Nombre max d'entiers consécutifs dans t[:i+l]
    while i+l<n:
        if t[i+l]==t[i+l-1]+1:
            l+=1
            if l>m:
                m=l
        else:
            i=i+l
            l=1
    return m

print(nombreConsMax(t))