Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls = [int(input()) for _ in range(n)]
ls.reverse()

result = []
for i in range(n-1):
    result.append(ls[i] - min(ls[i+1:]))

print(max(result))


Fixed submission:
n = int(input())
m = [int(input()) for _ in range(n)]

def fx(raw):
    min_n = raw[0]
    max_n = raw[1] - raw[0]
    for i in raw[1:]:
        if i - min_n >= max_n:
            max_n = i - min_n
        if i < min_n:
            min_n = i
    return max_n


if __name__ == '__main__':
    print(fx(m))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls = [int(input()) for _ in range(n)]

p = []
for i, x in enumerate(ls):
    if i+1 != len(ls):
        p.append(max(ls[i+1:])-x)

print(max(p))


Fixed submission:
n = int(input())
m = [int(input()) for _ in range(n)]

def fx(raw):
    min_n = raw[0]
    max_n = raw[1] - raw[0]
    for i in raw[1:]:
        if i - min_n >= max_n:
            max_n = i - min_n
        if i < min_n:
            min_n = i
    return max_n


if __name__ == '__main__':
    print(fx(m))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls = [int(input()) for _ in range(n)]

pp = [max(ls[i:])-x for i, x in enumerate(ls, 1) if i != len(ls)]

print(max(pp))


Fixed submission:
n = int(input())
m = [int(input()) for _ in range(n)]

def fx(raw):
    min_n = raw[0]
    max_n = raw[1] - raw[0]
    for i in raw[1:]:
        if i - min_n >= max_n:
            max_n = i - min_n
        if i < min_n:
            min_n = i
    return max_n


if __name__ == '__main__':
    print(fx(m))

Buggy python submission (verdict: Runtime Error):
n = int(input())
ls = [int(input()) for _ in range(n)]

#pp = [max(ls[i:])-x for i, x in enumerate(ls, 1) if i != len(ls)]

p = min(ls) - max(ls)

for i, x in enumerate(ls, 1):
    if i == len(pp):
        break
    if max(ls[i:]) - x > p:
        p = max(ls[i:]) - x

print(p)




Fixed submission:
n = int(input())
m = [int(input()) for _ in range(n)]

def fx(raw):
    min_n = raw[0]
    max_n = raw[1] - raw[0]
    for i in raw[1:]:
        if i - min_n >= max_n:
            max_n = i - min_n
        if i < min_n:
            min_n = i
    return max_n


if __name__ == '__main__':
    print(fx(m))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls = [int(input()) for _ in range(n)]

#pp = [max(ls[i:])-x for i, x in enumerate(ls, 1) if i != len(ls)]

p = min(ls) - max(ls)

for i, x in enumerate(ls, 1):
    if i == len(ls):
        break
    if max(ls[i:]) - x > p:
        p = max(ls[i:]) - x

print(p)



Fixed submission:
n = int(input())
m = [int(input()) for _ in range(n)]

def fx(raw):
    min_n = raw[0]
    max_n = raw[1] - raw[0]
    for i in raw[1:]:
        if i - min_n >= max_n:
            max_n = i - min_n
        if i < min_n:
            min_n = i
    return max_n


if __name__ == '__main__':
    print(fx(m))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls = [int(input()) for _ in range(n)]

p = min(ls) - max(ls)

for i, x in enumerate(ls, 1):
    if i == len(ls):
        break
    v = max(ls[i:]) - x
    if v > p:
        p = v
print(p)


Fixed submission:
n = int(input())
m = [int(input()) for _ in range(n)]

def fx(raw):
    min_n = raw[0]
    max_n = raw[1] - raw[0]
    for i in raw[1:]:
        if i - min_n >= max_n:
            max_n = i - min_n
        if i < min_n:
            min_n = i
    return max_n


if __name__ == '__main__':
    print(fx(m))