Getting run-error on test case 5 and 8

for i in range(r):
    if(l[i]>l[i+1]):
        flag=True
    elif(l[i]==l[i+1]):
        flag=False
        break
    if(l[i]<l[i+1]):
        ind=i+1
        break
for j in range(ind,r):
    if(l[j]<l[j+1]):
        flag=True
    else:
        flag=False
        break
if(l[r-1]<l[r]):
    if(flag!=False):
        flag=True
print(flag)

All the other test cases pass correctly.

Hi,
Try for this testcase
5
5
5
5
5
5
it should give you false

and
7
10
7
6
5
3
2
1
it should give true