if(ARRAY_LENGTH<=1):#If the array contains only one element, we return it (it's the stop condition of recursion)
returnARRAY
#Else
PIVOT=ARRAY[0]
LONGEST_SUB=[]#This array will contains the longest increasing sub array
foriinrange(1,ARRAY_LENGTH):
if(ARRAY[i]<PIVOT):#For each element from the array (except the pivot), if the element is smaller than the pivot, it won't figure on the sub array that contains the pivot
TEMPORARY_ARRAY=[elementforelementinARRAY[i:]ifelement>=ARRAY[i]]#But it cas figure in an increasing sub array starting from this element
TEMPORARY_ARRAY=longestSub(TEMPORARY_ARRAY)#We calculate the longest sub array that starts from this element
if(len(TEMPORARY_ARRAY)>len(LONGEST_SUB)):#And we save the longest sub array that begins from an element smaller than the pivot (in LONGEST_SUB)
LONGEST_SUB=TEMPORARY_ARRAY
TEMPORARY_ARRAY=[elementforelementinARRAY[1:]ifelement>=PIVOT]#Then we delete these elements (smaller than the pivot) from the initial array
TEMPORARY_ARRAY=[PIVOT]+longestSub(TEMPORARY_ARRAY)#And we calculate the longest sub array containing the pivot (in TEMPORARY_ARRAY)
if(len(TEMPORARY_ARRAY)>len(LONGEST_SUB)):#Then we compare the longest array between TEMPORARY_ARRAY and LONGEST_SUB