Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
	n = int(input())
	M = None
	R = int(input())
	S = 0
	tr = R
	for i in range(n - 1):
		a = int(input())
		if tr - a >= 0:
			continue
		else:
			M = tr - a if M is None and M < tr - a else M
			tr = a
	print(M)





Fixed submission:
if __name__ == '__main__':
	n = int(input())
	lists = list()

	for i in range(n):
		a = int(input())
		lists.append(a)

	S = None
	while len(lists) > 1:
		mini = min(lists)
		mini_ind = lists.index(mini)
		l = len(lists)

		if mini_ind + 1 == l:
			if S is None or S < lists[mini_ind] - lists[mini_ind - 1]:
				S = lists[mini_ind] - lists[mini_ind - 1]
			lists.pop(mini_ind)
			continue


		maxi = max(lists[mini_ind : l])
		T = maxi - mini

		if S is None or S < T:
			S = T

		lists = lists[0 : mini_ind]
		continue

	print(S)

Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
	n = int(input())
	lists = list()

	for i in range(n):
		a = int(input())
		lists.append(a)
	
	m = None

	for i in range(n - 1):
		for j in range(i + 1, n):
			m = lists[j] - lists[i] if m is None or m < lists[j] - lists[i] else m
	print(m)





Fixed submission:
if __name__ == '__main__':
	n = int(input())
	lists = list()

	for i in range(n):
		a = int(input())
		lists.append(a)

	S = None
	while len(lists) > 1:
		mini = min(lists)
		mini_ind = lists.index(mini)
		l = len(lists)

		if mini_ind + 1 == l:
			if S is None or S < lists[mini_ind] - lists[mini_ind - 1]:
				S = lists[mini_ind] - lists[mini_ind - 1]
			lists.pop(mini_ind)
			continue


		maxi = max(lists[mini_ind : l])
		T = maxi - mini

		if S is None or S < T:
			S = T

		lists = lists[0 : mini_ind]
		continue

	print(S)

Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
	n = int(input())
	lists = list()

	for i in range(n):
		a = int(input())
		lists.append(a)
	
	m = None

	for i in range(n - 1):
		j = max(lists[i + 1:n])
		m = j - lists[i] if m is None or m < j - lists[i] else m
	print(m)




Fixed submission:
if __name__ == '__main__':
	n = int(input())
	lists = list()

	for i in range(n):
		a = int(input())
		lists.append(a)

	S = None
	while len(lists) > 1:
		mini = min(lists)
		mini_ind = lists.index(mini)
		l = len(lists)

		if mini_ind + 1 == l:
			if S is None or S < lists[mini_ind] - lists[mini_ind - 1]:
				S = lists[mini_ind] - lists[mini_ind - 1]
			lists.pop(mini_ind)
			continue


		maxi = max(lists[mini_ind : l])
		T = maxi - mini

		if S is None or S < T:
			S = T

		lists = lists[0 : mini_ind]
		continue

	print(S)

Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
	n = int(input())
	M = int(input())
	m = M
	M_c = 0
	m_c = 0
	m_2 = 0

	for i in range(n - 1):
		count += 1
		a = int(input())
		if M <= a:
			M = a
			M_c = count
		elif m >= a:
			m, m_2 = a, m
			m_c = count if m > a else m_c

	if m_c < M_c:
		print(M - m)
	else:
		print(m_2 - m)




Fixed submission:
if __name__ == '__main__':
	n = int(input())
	lists = list()

	for i in range(n):
		a = int(input())
		lists.append(a)

	S = None
	while len(lists) > 1:
		mini = min(lists)
		mini_ind = lists.index(mini)
		l = len(lists)

		if mini_ind + 1 == l:
			if S is None or S < lists[mini_ind] - lists[mini_ind - 1]:
				S = lists[mini_ind] - lists[mini_ind - 1]
			lists.pop(mini_ind)
			continue


		maxi = max(lists[mini_ind : l])
		T = maxi - mini

		if S is None or S < T:
			S = T

		lists = lists[0 : mini_ind]
		continue

	print(S)