python – How does this comparing algorithm work?

Hello i have the following algorithm

A = (
    10,
    1,
    2,
    3,
    1,
    20,
    1,

    )
def algo1_original():
    stop = False
    i = 0
    n = (len(A)-1) # Python arrays starts at index 0 not 1
    while i <= n and not stop:
        j = 0
        found = False
        fail = False
        while j <= n and not fail:
            if A(i) < A(j):
                if found:
                    fail = True
                else:
                    found = True
            j = j + 1
        if (found and not(fail)):
            stop = True
        else:
            i = i +1

    if (stop):
        return A(i)
    else:
        return "failed"

How does it work? I can’t quite wrap my head around how it operates.

Any help is appreciated!