Problem:


  MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Maximum Profit

You can obtain profits from foreign exchange margin transactions. For example,  if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) &times; 1000 = 8000 yen.

  Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .

Input

The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.

Output

Print the maximum value in a line.

Constraints

  
$2 \leq n \leq 200,000$

  
$1 \leq R_t \leq 10^9$

Sample Input 1

6
5
3
1
3
4
3

Sample Output 1

3

Sample Input 2

3
4
3
2

Sample Output 2

-1



Sample input:
6
5
3
1
3
4
3


Sample output:
3

Submission status: Runtime Error

Solution code:
n = int(input())
a = int(input())
Max = -999999
Min = a
for i in range(n):
    x = int(input())
    if (Max < x - Min):
        Max = x - Min
    if ( x < Min):
        Min = x
print(Max)

Submission status: Runtime Error

Solution code:
n = int(input())
a = int(input())
Max = -999999
Min = a
for i in range(n):
    x = int(input())
    if (Max < x - Min):
        Max = x - Min
    if (x < Min):
        Min = x
print(Max)

Submission status: Runtime Error

Solution code:
n = int(input())
a = int(input())
Max = -999999
Min = a
for i in range(n):
    x = int(input())
    if (Max < (x - Min)):
        Max = x - Min
    if (x < Min):
        Min = x
print(Max)

Submission status: Runtime Error

Solution code:
n = int(input())
a = int(input())
Max = -9999999
Min = a
for i in range(n):
    x = int(input())
    if (Max < x - Min):
        Max = x - Min
    if (x < Min):
        Min = x
print(Max)

Submission status: Runtime Error

Solution code:
n = int(input())
a = int(input())
Max = -200000
Min = a
for i in range(n):
    x = int(input())
    if (Max < x - Min):
        Max = x - Min
    if (x < Min):
        Min = x
print(Max)

Submission status: Runtime Error

Solution code:
n = int(input())
a = int(input())
Max = -10 ** 9
Min = a
for i in range(n):
    x = int(input())
    if (Max < x - Min):
        Max = x - Min
    if (x < Min):
        Min = x
print(Max)

Submission status: Runtime Error

Solution code:
n=int(input())
r=[]
for i in range(n):
    r.append(int(input()))
#m=sorted(r, reverse=True)
p=max(r[1:])
q=min(r[:r.index(p)])
a=p-q
q=min(r[:len(r)-1])
#print(q)
p=max(r[r.index(q)+1:])
#print(p)
b=p-q
#print(b)
print(max(a,b))

Submission status: Runtime Error

Solution code:
n = int(input())
min_n = 0
max_n = -2 * 10**9
for i in range(n):
    x = int(input())
    min_n = min(x,min_n)
    max_n = max(max_n,x - min_n)
print max_n

Submission status: Runtime Error

Solution code:
import math

n = int(input())
nums = [int(input()) for i in range(n)]

minNum = nums[0]
maxDiff = -math.inf
for i in nums[1:]:
    diff = i - minNum
    if diff > maxDiff:
        maxDiff = diff
    if minNum > i:
        minNum = i

print(maxDiff)

Submission status: Runtime Error

Solution code:
t = []
n = int(input())
for i in range(n):
    t.append(int(input()))

for j range(1,n):
    for i range(j):
        maxv = max([maxv,t[j] - t[i]])
print(maxv)

Submission status: Runtime Error

Solution code:
t = []
n = int(input())
for i in range(n):
    t.append(int(input()))

for j in range(1,n):
    for i in range(j):
        maxv = max([maxv,t[j] - t[i]])
print(maxv)

Submission status: Runtime Error

Solution code:
t = []
n = int(input())
for i in range(n):
    t.append(int(input()))



'''
n = 6
t=[4,1,5,7,5,4]
'''


minv = t[0]
maxv = t[1] - t[0]
for j in range(1,n):
    maxv = max([maxv,t[j] - minv])
    minv = min([minv,t[j])
print(maxv)

Submission status: Runtime Error

Solution code:
import sys
n=int(input())
r=list(map(int,sys.stdin.read())
print(max([max(r[i+1:])-r[i]for i in range(n-1)]))

Submission status: Runtime Error

Solution code:
n=int(input())
r=[int(input())for _ in range(n)]
print(max([max(r[i+1:])-r[i]for i in range(min(r.remove(min(r))),n-1)]))

Submission status: Runtime Error

Solution code:
import sys

n = int(input())
r0 = int(input())
r1 = int(input())
max = r1 - r0
min = min(r1, r0)

for i in map(int, sys.stdin.readlines(())):
    if max < i - min:
        max = i - min
        if 0 > i - min:
            min = i
    elif min > i:
        min = 1

Submission status: Runtime Error

Solution code:
i=input
r=range
N=int(i())
A=(int(i()) for _ in r(N))
mp=A[1]-A[0]
mn=A[0]
for a in r(1,N):
    x=A[a]
    b=x-mn
    if mp<(b):mp=b
        if 0>b:mn=x
    if x<mn:mn=x
print(mp)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

def maximum_profit_1(n, R):
    maxv = R[1] - R[0]
    for j in range(1, n):
        for i in range(j):
            maxv = max(maxv, R[j]-R[i])

    return maxv

def maximum_profit_2(n, R):
    minv = R[0]
    for j in range(1, N):
        maxv = max(maxv, R[j]-minv)
        minv = min(minv, R[j])

    return maxv

if __name__ == '__main__':

    n = int(input())
    R = [ int(input()) for i in range(n)]

    ans = maximum_profit_2(n ,R)
    print(ans)

Submission status: Runtime Error

Solution code:
b,s=-1e7,1e7
for _ in range(int(input())):
 r=int(input())
 b,s=max(b,c-s),min(s,c)
print(b)

Submission status: Runtime Error

Solution code:
N = input()
R = list(map(int, input().split()))
answer = R[1] - R[0]
i = 0

while i < len(R) :
    k = i + 1
    while k < len(R) :
        if R[k] - R[i] > answer :
            answer = R[k] -R[i]
        k = k + 1
    i = i + 1

print(answer)

Submission status: Runtime Error

Solution code:
n = int(input())

before = int(input())
current = int(input())
diffMax = current - before
for i in range(n - 1):
  number = int(input())
  diff = number - current
  diffMax = max(diff, diffMax)
  current = min(current, number)
print(diffMax)

Submission status: Runtime Error

Solution code:
numbers = []
for line in sys.stdin:
	numbers.append(int(line))

answer = numbers[2] - numbers[1]

count = 1
while count < len(numbers) - 1:
	target = max(numbers[count : ])
	if target -  numbers[count] > answer :
		answer = target -  numbers[count]
	count += count

print(answer)

Submission status: Runtime Error

Solution code:
# coding: UTF-8
n = int(raw_input())
value_list = []
diff_indx1 = 0
diff_indx2 = 0
value_list.append(int(raw_input()))
if i == 1:
    diff = value_list[1] - value_list[0]
    diff_indx1 = 1
if value_list[i] >= value_list[diff_indx1]:
    for j in range(i):
        diff2 = value_list[i] - value_list[j]
        if diff <= diff2:
            diff = diff2
            diff_indx1 = i
            diff_indx2 = j
            #print("{}:{} - {} = {}").format(diff_indx1,value_list[i],value_list[j],diff)
elif value_list[diff_indx2] > value_list[i]:
    diff_indx2 = i
    diff_indx1 = i
print diff

Submission status: Runtime Error

Solution code:
n = int(raw_input())
gain = -999999999
max = 1000000000
for i in n:
    new = int(raw_input())
    if max < new:
        if gain < max - new:
            gain =  max - new
    else:
        max = new
print diff

Submission status: Runtime Error

Solution code:
n = int(raw_input())
gain = -999999999
max = 1000000000
for i in n:
    new = int(raw_input())
    if max < new:
        if gain < max - new:
            gain =  max - new
    else:
        max = new
print gain

Submission status: Runtime Error

Solution code:
n = int(input())
min_r, max_d = int(input()), - 10**9
for in range(n - 1):
    r = int(input())
    max_d = max(max_d, r - min)
    min_r = min(min_r, r)
print(max_d)

Submission status: Runtime Error

Solution code:
n = int(input())
min_r, max_d = int(input()), - 10**9
for _ in range(n - 1):
    r = int(input())
    max_d = max(max_d, r - min)
    min_r = min(min_r, r)
print(max_d)

Submission status: Runtime Error

Solution code:
# coding: UTF-8
n = int(raw_input())
value_list = []
diff_indx1 = 0
diff_indx2 = 0
diff = None　#変数の初期化
for i in range(n):
    value_list.append(int(raw_input()))
    if i == 1:# diffの初期化
        diff = value_list[1] - value_list[0]
        diff_indx1 = 1
    if value_list[i] >= value_list[diff_indx1]:#引かれる数の更新
        diff2 = value_list[i] - value_list[diff_indx2]
        if diff <= diff2:
            diff = diff2
            diff_indx2 = diff_indx1
            diff_indx1 = i
    if value_list[diff_indx2] > value_list[i]:#引く数の更新と引かれる数のリセット
        diff_indx2 = i
        diff_indx1 = i
print diff

Submission status: Runtime Error

Solution code:
from sys import stdin

N,*datas = [int(i) for i in stdin.readlines()]
now_max = max(datas[1:])
max_index = (N-1) - datas[::-1].index(now_max)
now_min = min(datas)
min_index = datas.index(_min)

if max_index > min_index:
    diff = now_max - _min
else:
    diff = now_max - datas[0]
    
    for i in range(1,N-1):
        if i == max_index:
            now_max = max(datas[i+1:])
            max_index = datas.index(now_max,i+1)
        new_diff = now_max - datas[i]
        if diff < new_diff:
            diff = new_diff

print(diff)

Submission status: Runtime Error

Solution code:
from sys import stdin

N,*datas = [int(i) for i in stdin.readlines()]
now_max = max(datas[1:])
max_index = (N-1) - reversed(datas).index(now_max)
_min = min(datas)
min_index = datas.index(_min)

if max_index > min_index:
    diff = now_max - _min
else:
    diff = now_max - datas[0]
    
    for i in range(1,N-1):
        if i == max_index:
            now_max = max(datas[i+1:])
            max_index = datas.index(now_max,i+1)
        new_diff = now_max - datas[i]
        if diff < new_diff:
            diff = new_diff

print(diff)

Submission status: Runtime Error

Solution code:
import sys
s=1e10,b=-s
input()
for r in map(int,sys.stdin):
 if b<r-s:b=r-s
 if s>r:s=r
print(b)

Submission status: Runtime Error

Solution code:
n = input()
r = [input() for i in range(n)]

r_temp_min = r[0]
ans = r[1]-r[0]

for r_i in r[1:]:
    if ans < (r_i - r_temp_min):
        ans = r_i - r_temp_min

for i,r_i in enumerate(r):
    if r_temp_min <= r_i:
        continue
    r_temp_min = r_i

    for r_j in enumerate(r[i:]):
        if ans < (r_j - r_i):
            ans = r_j - r_i

print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
nums=[]
for i in range(n):
    nums.appemd(int(input()))
for i in range(1,n):
    v=nums[i]
    j=i-1
    while j>=0 and nums[j]>v:
        nums[j+1]=nums[j]
        j-=1
    nums[j+1]=v
print(nums[n-1]-nums[0])

Submission status: Runtime Error

Solution code:
import sys
  
input()
minv = int(input())
maxv = -1000000000
  
for r in map(int,sys.stdin.readlines()):
  m = r-minv
  if maxv < m: 
    maxv = m
    if m < 0: minv = r
  elif m < 0: minv = r
  
print(maxv

Submission status: Runtime Error

Solution code:
import sys

length = int(sys.stdin.readline())
value =[ int(num) for num in sys.stdin.readlines() ]
minv = value[0]
maxv = value[1] - value[0]

for i in range(1,length):
    maxv = max(maxv,value[i] - minv)
    minv = min(minv,value[i])

print(maxv)

return 0

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*
import sys
#if False:
if True:
    fh=open('ALDS1_1_D6.txt','r')
else:
    fh=sys.stdin
input=fh.readline

def main():
    n = int(input())
    a=[]
    for _ in range(n):
        a.append(int(input()))

    pmax=a[1]-a[0]
    for k in range(0, n-1):
        p=max(a[k+1:])-a[k] 
        if p > pmax:
            pmax=p

    print(pmax)
    
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys
 
if __name__ == ‘__main__’:
    args = sys.argv
    prices = map(int, args[1:])
    min = prices[1]

    max_profit = 0
    for price in prices:
        if min > price:
            min = price
        max_profit = price - min

    return max_profit

Submission status: Runtime Error

Solution code:
import sys
 
if __name__ == ‘__main__’:
    args = sys.argv
    prices = map(int, args[1:])
    min = prices[0]

    max_profit = 0
    for price in prices:
        if min > price:
            min = price
        max_profit = price - min

    return max_profit

Submission status: Runtime Error

Solution code:
import sys
 
args = sys.argv
prices = map(int, args[1:])
min = prices[0]

max_profit = 0
for price in prices:
    if min > price:
        min = price
    max_profit = price - min

print(max_profit)

Submission status: Runtime Error

Solution code:
import sys
 
args = sys.argv
prices = map(int, args[2:])
min = prices[0]
max_profit = 0

for price in prices:
    if min > price:
        min = price
    max_profit = price - min

print(max_profit)

Submission status: Runtime Error

Solution code:
import sys
 
args = sys.argv
prices = list(map(int, args[2:]))
min = prices[0]
max_profit = 0

for price in prices:
    if min > price:
        min = price
    max_profit = price - min

print(max_profit)

Submission status: Runtime Error

Solution code:
import sys
 
args = sys.argv
prices = list(map(int, args[2:]))
min = prices[0]
max_profit = 0

for price in prices[1:]:
    max_profit = price - min
    if min > price:
        min = price

print(max_profit)

Submission status: Runtime Error

Solution code:
n = input()
prices = list()
for idx in range(n):
    tmp = index()
    prices.append(tmp)

minp = prices[0]
maxv = prices[1] - prices[0]

for price in prices:
    maxp = max(maxp, price - min)
    minv = min(minv, price)

print(maxp)

Submission status: Runtime Error

Solution code:
n = int(input())

maxv = -2000000000

lst = [int(input()) for _ in range(n)]

minv = lst[0]

for i in range(n + 1):
   maxv = max([maxv, lst[i] - minv])
   minv = min([minv, lst[i])

print(maxv)

Submission status: Runtime Error

Solution code:
n = int(input())

maxv = -2000000000

lst = [int(input()) for _ in range(n)]

minv = lst[0]

for i in range(1, n):
   maxv = max([maxv, lst[i] - minv])
   minv = min([minv, lst[i])

print(maxv)

Submission status: Runtime Error

Solution code:
n = int(input())
 
maxv = -2000000000
 
 
minv = int(intput())
 
for i in range(1, n):
   cur = int(input())
   maxv = max([maxv, cur - minv])
   minv = min([minv, cur])
 
print(maxv)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;
    cin >> n;
    for(int i =0; i<n; i++) cin >> R[i];
    int maxv = -2000000000;
    int minv = R[0];
    for(int i =1; i<n; i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    cout << maxv << endl;
    return 0;
}

Submission status: Runtime Error

Solution code:
alues = set_values()
max_value = min(values) - max(values)
for i in range(1, int(input())):
	for j in range(0, i-1):
		print(i, j, len(values))
		if max_value < (values[i] - values[j]):
			max_value = (values[i] - values[j])
print(max_value)

Submission status: Runtime Error

Solution code:
values = set_values()
max_value = min(values) - max(values)
for i in range(1, int(input())):
	for j in range(0, i-1):

		print(i, j, len(values))
		if max_value < (values[i] - values[j]):
			max_value = (values[i] - values[j])

print(max_value)

Submission status: Runtime Error

Solution code:
n = input()

r = []
for i in range(n):
    r.append(input())

maxv =  int(-20000000)
minv = int r[0]

for i in ranfe(n)
    maxv = max(maxv, r[i]-minv)
    minv = min(minv, r[i])

print(maxv)

Submission status: Runtime Error

Solution code:
n = input()

r = []
for i in range(n):
    r.append(input())

maxv =  int(-20000000)
minv = int(r[0])

for i in ranfe(n):
    maxv = max(maxv, r[i]-minv)
    minv = min(minv, r[i])

print(maxv)

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
nowmin = a[0]
for i in range(n):
  a.append(int(input()))
ans = a[1]-a[0]
for i in range(n-1):
 if a[i] < nowmin
  k = max(a[i+1:]) - a[i]
  if k > ans:
    ans =  k
    
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
nowmin = a[0]
for i in range(n):
  a.append(int(input()))
ans = a[1]-a[0]
for i in range(n-1):
 if a[i] < nowmin:
  k = max(a[i+1:]) - a[i]
  if k > ans:
    ans =  k
    
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
nowmin = a[0]
for i in range(n):
  a.append(int(input()))
ans = a[1]-a[0]
for i in range(n-1):
  if a[i] < nowmin:
    k = max(a[i+1:]) - a[i]
    if k > ans:
      ans =  k
    
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
nowmin = a[0] + 1
nowmax = max(a[1:])
ans = a[1]-a[0]
for i in range(n-1):
  if a[i] < nowmin:
    k = nowmax - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]
  elif a[i] == nowmax]
    nowmax = max(a[i+1])
    
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
nowmin = a[0] + 1
nowmax = max(a[1:])
ans = a[1]-a[0]
for i in range(n-1):
  if a[i] < nowmin:
    k = nowmax - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]
  elif a[i] == nowmax:
    nowmax = max(a[i+1])
    
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())

maxv =  int(-20000000)
minv = int(input())

for i in range(n):
    r= int(input())
    maxv = max(maxv, r-minv)
    minv = min(minv, r)

print(maxv)

Submission status: Runtime Error

Solution code:
n = int(input())

maxv =  int(-20000000)
minv = int(input())

for i in range(n):
    r= int(input())
    maxv = max(maxv, r - minv)
    minv = min(minv, r)

print(maxv)

Submission status: Runtime Error

Solution code:
n = int(input())
a =[int(input()) for i in range(n)]
b = []
for i in range(n):
    for j in range(i+1, n+1):
        b.append(a[j]-a[i])
    
b.sort()
print(b[n-1])

Submission status: Runtime Error

Solution code:
n = int(input())
a =[int(input()) for i in range(n)]
b = []
for i in range(n):
    for j in range(i+1, n+1):
        b.append(a[j]-a[i])
    
b.sort()
b.pop()

Submission status: Runtime Error

Solution code:
n = int(input())
a =[int(input()) for i in range(n)]
b = []
for i in range(n):
    for j in range(i+1, n+1):
        b.append(a[j]-a[i])
    
c = sorted(b, reverse = True)
print(c[0])

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
for i in range(n):
    a[i] = int(input())
b = []
for i in range(n):
    for j in range(i+1, n+1):
        b.append(a[j]-a[i])
    
c = sorted(b, reverse = True)
print(c[0])

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
b = []
for i in range(n):
    for j in range(i+1, n+1):
        b.append(a[j]-a[i])
    
c = sorted(b, reverse = True)
print(c[0])

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
maximum = a[1]-a[0]
minimum = min(a[0], a[1])
for i in range(n):
    minimum = min(minimum, a[i])
    maximum = max(maximum, a[i] - minumum)

    
print(maximum)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
ma = a[1]-a[0]
mi = a[0]
for i in range(1,n+1):
    mi = min(mi, a[i])
    ma = max(ma, a[i] - mi)
print(ma)

Submission status: Runtime Error

Solution code:
#
# P.48 O(n^2)となる単純な回答（比較用）
#
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_D
#
import sys

values = [int(input()) for i in range(input())]

maxv = - sys.maxsize - 1

for i in values:
    for j in values:
        val = i - j
        if maxv < val:
            maxv = val

print(maxv)

Submission status: Runtime Error

Solution code:
import sys

values = [int(input()) for i in range(int(input()))]

maxv = - sys.maxsize - 1
minv = values[0]

for value in enumerate(values):
    maxv = max(maxv, value - minv)
    minv = min(minv, value)         # 今までの最小値を保持(自分と自分を比較しない様に、最大値の評価後に計算)

print(maxv)

Submission status: Runtime Error

Solution code:
import sys

values = [int(input()) for i in range(int(input()))]

maxv = - sys.maxsize - 1
minv = values[0]

for value in enumerate(values):
    maxv = max(maxv, value - minv)
    minv = min(minv, value) 

print(maxv)

Submission status: Runtime Error

Solution code:
import sys

input_amount = int(input())
values = [int(input()) for i in range(input_amount)]

maxv = - sys.maxsize - 1
minv = values[0]

for value in enumerate(values):
    maxv = max(maxv, value - minv)
    minv = min(minv, value) 

print(maxv)

Submission status: Runtime Error

Solution code:
import sys

values = [int(input()) for i in range(int(input()))]
maxv = - sys.maxsize - 1
minv = values[0]

for value in enumerate(values):
    maxv = max(maxv, value - minv)
    minv = min(minv, value) 
print(maxv)

Submission status: Runtime Error

Solution code:
import sys

values = [int(input()) for i in range(int(input()))]
maxv = - 1000000
minv = values[0]

for value in enumerate(values):
    maxv = max(maxv, value - minv)
    minv = min(minv, value)
print(maxv)

Submission status: Runtime Error

Solution code:
values = [int(input()) for i in range(int(input()))]
maxv = - 1000000
minv = values[0]

for value in enumerate(values):
    maxv = max(maxv, value - minv)
    minv = min(minv, value)
print(maxv)

Submission status: Runtime Error

Solution code:
values = [int(input()) for i in range(int(input()))]
maxv = - 1000000
minv = values[0]

for value in enumerate(values):
    maxv = max(maxv, value - minv)
    # minv = min(minv, value)
print(maxv)

Submission status: Runtime Error

Solution code:
values = [int(input()) for i in range(int(input()))]
maxv = - 1000000
minv = values[0]

for value in enumerate(values):
    # maxv = max(maxv, value - minv)
    # minv = min(minv, value)
print(maxv)

Submission status: Runtime Error

Solution code:
values = [int(input()) for i in range(int(input()))]
maxv = - 1000000
minv = values[0]

for val in enumerate(values):
    # maxv = max(maxv, val - minv)
    # minv = min(minv, val)
print(maxv)

Submission status: Runtime Error

Solution code:
values = [int(input()) for i in range(int(input()))]
maxv = - 1000000
minv = values[0]

for val in enumerate(values):
    maxv = max(maxv, val - minv)
print(maxv)

Submission status: Runtime Error

Solution code:
values = [int(input()) for i in range(int(input()))]
maxv = - 1000000
minv = values[0]

for val in enumerate(values):
    maxv = max(maxv, (val - minv))
print(maxv)

Submission status: Runtime Error

Solution code:
values = [int(input()) for i in range(int(input()))]
maxv = -1000000
minv = values[0]

for val in enumerate(values):
    maxv = max(maxv, (val - minv))
print(maxv)

Submission status: Runtime Error

Solution code:
values = [int(input()) for i in range(int(input()))]
maxv = -1000000
minv = values[0]

for val in enumerate(values):
    if (val - minv) > maxv:
        maxv = val - minv
print(maxv)

Submission status: Runtime Error

Solution code:
n = float(input())
A = []

for i in range(n): A.append(float(input()))

B = A[:-1]
mini = min(B)
min_idx = B.index(mini)
C = A[min_idx+1:]
maxi = max(C)

print(maxi - mini)

Submission status: Runtime Error

Solution code:
import sys

values = [int(input()) for i in range(int(input()))]
maxv = - sys.maxsize - 1
minv = values[0]

for val in enumerate(values):
    maxv = max(maxv, (val - minv))
    minv = min(minv, val)
print(maxv)

Submission status: Runtime Error

Solution code:
import sys

values = [int(input()) for i in range(int(input()))]
maxv = - sys.maxsize - 1
minv = values[0]

for val in enumerate(values):
    maxv = max(maxv, (val - minv))
print(maxv)

Submission status: Runtime Error

Solution code:
import sys

values = [int(input()) for i in range(int(input()))]
maxv = - sys.maxsize - 1
minv = values[0]

for val in enumerate(values):
    minv = min(minv, val)
print(maxv)

Submission status: Runtime Error

Solution code:
import sys

values = [int(input()) for i in range(int(input()))]
maxv = - sys.maxsize - 1
minv = values[0]

for val in enumerate(values):
    if maxv < (val - minv):
        maxv = val - minv
    if minv > val:
        minv = val
print(maxv)

Submission status: Runtime Error

Solution code:
#16D8101012J 伊藤惇 dj Python3
import sys

def Maximum_Profit(n,A):
    Max=-sys.maxint-1
    for i in range(n-1):
        tmp=(max(A[i+1:])-A[i])
        if Max<tmp:
            Max=tmp
    return Max

if __name__ == "__main__":
    n=int(input())
    A=[]
    for i in range(n):
        A.append(int(input()))
    Max=Maximum_Profit(n,A)
    print(Max)

Submission status: Runtime Error

Solution code:
n = int(input())
A = [int(input()) for i in range(n)]
max = A[1]-A[0]
min = A[0]

for i in range(1,n-1):
    if(min > A[i]):
        for j in range(j,n-1):
            if(max < A[j+1]-A[i]):
                max = A[j+1]-A[i]
print(max)

Submission status: Runtime Error

Solution code:
n = int(input())
A = [int(input()) for i in range(n)]
max = A[1]-A[0]
min = A[0]

for i in range(1,n-2):
    if(min > A[i]):
        for j in range(j,n-1):
            if(max < A[j+1]-A[i]):
                max = A[j+1]-A[i]
print(max)

Submission status: Runtime Error

Solution code:
# -*- coding=utf-8 -*-
price = [int(input()) for p in range(int(input()))]

# Nのコード　→ いけるぞ！
# まずは最小値を調査
min_ = price[0]
index_ = 0
for i in range(1, len(price)):
    if price[i] < min_:
        min_ = price[i]
        index_ = i

# 次は最大値を調査
print(max(price[index_ + 1:]) - min_)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [input() for i in range(n)]
margin = max(a) - min(a)
print(margin)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [input() for i in range(n)]
margin = max(a) - min(a)
print(min(a))

Submission status: Runtime Error

Solution code:
n = int(input())
a = [input() for i in range(n)]

min_value = -200000

for a in range(a)
    max_mergin = max(max_mergin,a - min_value)
    min_value = min(min_value,a)
print(max_mergin)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [input() for i in range(n)]

min_value = -200000

for a in range(a)
    max_value = max(max_value,a - min_value)
    min_value = min(min_value,a)
print(max_value-min_value)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [input() for i in range(n)]

min_value = -200000

for a in range(a)
    max_value = max(max_value,a - min_value)
    min_value = min(min_value,a)
print(max_value)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [input() for i in range(n)]

max_mergin = -200000
min_value = a[0]
for abc in range(a):
    max_mergin = max(max_mergin,abc - min_value)
    min_value = min(min_value,abc)
    
print(max_mergin)

Submission status: Runtime Error

Solution code:
#coding:utf-8

n = int(input())
minv = pri_list[0]
maxv = -10000000000
for i in range(1,n-1):
    price = int(input())
    maxv = max([maxv, price - minv])
    minv = min([minv, price])

print(maxv)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]

max_mergin = -20000000000
min_value = a[0]
for abc in range(1,a):
    max_mergin = max(max_mergin, a[abc] - min_value)
    min_value = min(min_value,  a[abc])
    
print(max_mergin)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]

minv = R[0]
maxv = R[1] - R[0]
for j in range(1, n):
	if (maxv < R[j] - minv):
		maxv = R[j] - minv
	if (R[j] < minv):
		minv = R[j]
    
print(maxv)

Submission status: Runtime Error

Solution code:
import numpy as np


def maximum_profit(rs):
    ans = rs[1] - rs[0]
    for i in range(n):
        for j in range(i + 1, n):
            if ans < rs[j] - rs[i]:
                ans = rs[j] - rs[i]
    return ans


n = int(input())
rs = []
for _ in range(n):
    r = int(input())
    rs.append(r)

print(maximum_profit(rs))

Submission status: Runtime Error

Solution code:
n = input()
n = int(n)
maxv = -20000000
list = []

i = 1
while(i<n):
	x = input()
	x = int(x)
	list = list.append(x)
	i = i + 1

minv = list[0]
i = 1
while(i<n):
	maxv = max(maxv, list[i]-minv)
	minv = min(minv, list[i])
	i = i + 1

print(maxv)

Submission status: Runtime Error

Solution code:
n = input()
n = int(n)
maxv = -20000000
list = []

i = 0
while(i<n):
	x = input()
	x = int(x)
	list = list.append(x)
	i = i + 1

minv = list[0]
i = 1
while(i<n):
	maxv = max(maxv, list[i]-minv)
	minv = min(minv, list[i])
	i = i + 1

print(maxv)

Submission status: Runtime Error

Solution code:
n = input()
maxv = -20000000
list = []

i = 0
while(i<n):
	x = input()
	list = list.append(x)
	i = i + 1

minv = list[0]
i = 1
while(i<n):
	maxv = max(maxv, list[i]-minv)
	minv = min(minv, list[i])
	i = i + 1

print(maxv)

Submission status: Runtime Error

Solution code:
n = input()
n = int(n)
list = []

i = 0
while(i<n):
	x = input()
	list[i] = x
	i = i + 1

maxv = -20000000
minv = list[0]
i = 1
while(i<n):
	maxv = max(maxv, list[i]-minv)
	minv = min(minv, list[i])
	i = i + 1

print(maxv)

Submission status: Runtime Error

Solution code:
n = input()
n = int(n)
list = []

i = 0
while(i<n):
	x = input()
	x = int(x)
	list[i] = x
	i = i + 1

maxv = -20000000
minv = list[0]
i = 1
while(i<n):
	if(maxv >= list[i]-minv):
		maxv = maxv
	else:
		maxv = list[i]-minv
	
	if(minv <= list[i]):
		minv = minv
	else:
		minv = list[i]
	i = i + 1

print(maxv)

Submission status: Runtime Error

Solution code:
n = input()
n = int(n)
list = []

i = 0
while(i<n):
	x = input()
	x = int(x)
	list[i] = x
	i = i + 1

maxv = -20000000
minv = list[0]
i = 1
while(i<n):
	if(maxv >= list[i]-minv):
		maxv = maxv
	else:
		maxv = list[i]-minv
	
	if(minv <= list[i]):
		minv = minv
	else:
		minv = list[i]
	i = i + 1

	print(maxv)

Submission status: Runtime Error

Solution code:
n=int(input())
tmp=0
s=int(input())
for int i in range(n-1):
    t=int(input())
    if t<s && t-s<tmp:
        tmp=t-s
        s=t
print(tmp)

Submission status: Runtime Error

Solution code:
n=int(input())
tmp=0
s=int(input())
for int i in range(n-1):
    t=int(input())
    if t>s && t-s>tmp:
        tmp=t-s
    if t<s:
        s=t
print(tmp)

Submission status: Runtime Error

Solution code:
n=int(input())
tmp=0
s=int(input())
for int i in range(n-1):
    t=int(input())
    if t>s && t-s>tmp:
        tmp=t-s
    elif t<s:
        s=t
print(tmp)

Submission status: Runtime Error

Solution code:
n=int(input())
tmp=0
s=int(input())
for int i in range(n-1):
    t=int(input())
    if t>s && t-s>tmp:
        tmp=t-s
    else:
        s=t
print(tmp)

Submission status: Runtime Error

Solution code:
n=int(input())
tmp=0
s=int(input())
for int i in range(n-1):
	t=int(input())
	if t>s && t-s>tmp:
		tmp=t-s
	else:
		s=t
print(tmp)

Submission status: Runtime Error

Solution code:
n=int(input())
tmp=0
s=int(input())
for int i in range(n-1):
	t=int(input())
	if t>s && t-s>tmp:
		tmp=t-s
	elif t<s:
		s=t
print(tmp)

Submission status: Runtime Error

Solution code:
n=int(input())
tmp=0
s=int(input())
for i in range(n-1):
	t=int(input())
	if t>s && t-s>tmp:
		tmp=t-s
	elif t<s:
		s=t
print(tmp)

Submission status: Runtime Error

Solution code:
N = input()
N = int(N)
l = [input() for i in range(N)]
ma = -100
for i in range(0,len(l)-1):
    for j in range(i+1,len(l)):
        if(l[j] - l[i] > ma):
            ma = l[j] - l[i]
print(ma)