Buggy python submission (verdict: Time Limit Exceeded):
#-*- coding:utf-8 -*-

def main():
    n , data = input_data()
    vMax = float('-inf')

    i = 1
    for i, Ri in enumerate(data):
        for Rj in data[i+1:]:
            n = Rj - Ri
            if vMax < n:
                vMax = n
    print(vMax)

def input_data():
    n = int(input())
    lst = [int(input()) for i in range(n)]
    return (n , lst)

if __name__ == '__main__':
    main()

Fixed submission:
#-*- coding:utf-8 -*-

def main():
    n , data = input_data()
    vMax = float('-inf')
    vMin = data.pop(0)

    for Rj in data:
        if vMax < Rj - vMin:
            vMax = Rj - vMin
        if vMin > Rj:
            vMin = Rj

    print(vMax)

def input_data():
    n = int(input())
    lst = [int(input()) for i in range(n)]
    return (n , lst)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#-*- coding:utf-8 -*-

def main():
    n , data = input_data()
    vMax = float('-inf')

    i = 1
    minIndex = min(enumerate(data) , key = lambda x:x[1])[0]
    for i, Ri in enumerate(data):
        if data[i+1:]:
            n = max(data[i+1:]) - Ri
            if vMax < n:
                vMax = n

        if i == minIndex: # Ri???????°???????????????¨????????????????¨??????????
            break

    print(vMax)

def input_data():
    n = int(input())
    lst = [int(input()) for i in range(n)]
    return (n , lst)

if __name__ == '__main__':
    main()

Fixed submission:
#-*- coding:utf-8 -*-

def main():
    n , data = input_data()
    vMax = float('-inf')
    vMin = data.pop(0)

    for Rj in data:
        if vMax < Rj - vMin:
            vMax = Rj - vMin
        if vMin > Rj:
            vMin = Rj

    print(vMax)

def input_data():
    n = int(input())
    lst = [int(input()) for i in range(n)]
    return (n , lst)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#-*- coding:utf-8 -*-

def main():
    n , data = input_data()
    vMax = float('-inf')

    i = 1
    minIndex = min(enumerate(data) , key = lambda x:x[1])[0]
    maxIndex = max(enumerate(data) , key = lambda x:x[1])[0]
    for i, Ri in enumerate(data):
        if data[i+1:]:
            if maxIndex < i + 1:
                maxIndex, Rj= max(enumerate(data[i+1:]) , key = lambda x:x[1])
                maxIndex += i + 1
            else:
                Rj = data[maxIndex]

            n = Rj - Ri
            if vMax < n:
                vMax = n

        if i == minIndex: # Ri???????°???????????????¨????????????????¨??????????
            break

    print(vMax)

def input_data():
    n = int(input())
    lst = [int(input()) for i in range(n)]
    return (n , lst)

if __name__ == '__main__':
    main()

Fixed submission:
#-*- coding:utf-8 -*-

def main():
    n , data = input_data()
    vMax = float('-inf')
    vMin = data.pop(0)

    for Rj in data:
        if vMax < Rj - vMin:
            vMax = Rj - vMin
        if vMin > Rj:
            vMin = Rj

    print(vMax)

def input_data():
    n = int(input())
    lst = [int(input()) for i in range(n)]
    return (n , lst)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#-*- coding:utf-8 -*-

def main():
    n , data = input_data()
    vMax = float('-inf')

    i = 1
    minIndex = min(enumerate(data) , key = lambda x:x[1])[0]
    maxIndex = max(enumerate(data) , key = lambda x:x[1])[0]
    for i, Ri in enumerate(data):
        if data[i+1:]:
            if maxIndex < i + 1:
                maxIndex, Rj= max(enumerate(data[i+1:]) , key = lambda x:x[1])
                maxIndex += i + 1
            else:
                Rj = data[maxIndex]

            n = Rj - Ri
            if vMax < n:
                vMax = n

        if i == minIndex: # Ri???????°???????????????¨????????????????¨??????????
            break

    print(vMax)

def input_data():
    n = int(input())
    lst = [int(input()) for i in range(n)]
    return (n , lst)

if __name__ == '__main__':
    main()

Fixed submission:
#-*- coding:utf-8 -*-

def main():
    n , data = input_data()
    vMax = float('-inf')
    vMin = data.pop(0)

    for Rj in data:
        if vMax < Rj - vMin:
            vMax = Rj - vMin
        if vMin > Rj:
            vMin = Rj

    print(vMax)

def input_data():
    n = int(input())
    lst = [int(input()) for i in range(n)]
    return (n , lst)

if __name__ == '__main__':
    main()