Problem:


Score : 200 points

Problem Statement

You are given an integer sequence A of length N.
Find the maximum absolute difference of two elements (with different indices) in A.

Constraints

2 \leq N \leq 100

1 \leq A_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Print the maximum absolute difference of two elements (with different indices) in A.

Sample Input 1

4
1 4 6 3

Sample Output 1

5

The maximum absolute difference of two elements is A_3-A_1=6-1=5.

Sample Input 2

2
1000000000 1

Sample Output 2

999999999

Sample Input 3

5
1 1 1 1 1

Sample Output 3

0



Sample input:
4
1 4 6 3


Sample output:
5

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input()))

print(max(A) - min(A))

Submission status: Runtime Error

Solution code:
n=int(input())
a=sorted(map(int,input()))
print(a[-1]-a[0])

Submission status: Runtime Error

Solution code:
n=int(input())
a=sorted(map(int,input()))
print(a[:-1]-a[0])

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
ma=max(a)-min(a)
print(ma

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split())
print(max(A)-min(A))

Submission status: Runtime Error

Solution code:
N = int(input())
A = map(int, input().split())

As = A.sort()
ans = As[len(N)-1] - As[0]
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a_list = list(map(int, input().split())
              
a_sorted = sorted(a_list)
              
print(a_sorted[-1] - a_sorted[0])

Submission status: Runtime Error

Solution code:
n = int(input())
a_list = list(map(int, input().split())
              
a_sorted = sorted(a_list)
              
print(a_sorted[-1] - a_sorted[0]

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(a) for a in input(" ")]
max = A[0]
min = A[0]
for a in A[1:]:
  if a < min:
    min = a
  elif a > max:
    max = a
print(max-min)

Submission status: Runtime Error

Solution code:
N=input()
A=list(map(int, input().split()))
A.sort()
print(A[N-1]-A[0])

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(intm input().split()))

print(max(A) - min(A))

Submission status: Runtime Error

Solution code:
H = list(map(int, input().split())
print(max(H)-min(H))

Submission status: Runtime Error

Solution code:
n=int(input()) 
num=list(int,input().split())
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    dif=abs(num[i]-num[j])
    if dif>ans:
      ans=dif
print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input.split))
print(max(A)-min(A))

Submission status: Runtime Error

Solution code:
x = [int(i) for i in input().split()]
seq = x[1:]
print(max(seq)-min(seq))

Submission status: Runtime Error

Solution code:
import sys
n = int(input())
a = list(map(int, input().split())).sorted()
print(a[n-1] - a[0])

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort()

# range=A[N-1]-A[0]

range = 0

for i in range(N):
    for j in range(i+1,N):
        x = A[j]-A[i]
        range = max([range,x])

print(range)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort()
range = 0

for i in range(N+1):
    for j in range(i+1,N+1):
        x = A[j]-A[i]
        range = max([range,x])

print(range)

Submission status: Runtime Error

Solution code:
N = int(input())
num_lists = list(map(int, input().split))
max_num = max(num_lists)
min_num = min(num_lists)
ans = max_num - min_num
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
num_lists = list(map(int, input().split))
ans = - 1

for i in num_lists:
  for j in num_lists:
    diff = abs(i - j)
    if diff > ans:
      ans = diff

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
num_lists = list(map(int, input().split))
ans = 0

for i in num_lists:
  for j in num_lists:
    diff = abs(i - j)
    if diff > ans:
      ans = diff

print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
A.sort()
prit(A[-1]-A[0])

Submission status: Runtime Error

Solution code:
input()
num_list = [int(x) for x in input().split()]

print(num_list.max - num_list.min )

Submission status: Runtime Error

Solution code:
N = input()
string_list = input().rstrip().split()
l = [int(x) for x in string_list]
_max = 0
_min = l[0]
for t in l:
  if _max < t:
    _max = t
  if _min > t:
    _min = t  
return _max - _min

Submission status: Runtime Error

Solution code:
N = input()
l = [int(x) for x in input().rstrip().split()]
_max = 0
_min = l[0]
for t in l:
  if _max < t:
    _max = t
  if _min > t:
    _min = t  
return _max - _min

Submission status: Runtime Error

Solution code:
N = input()
l = [int(input()) for i in range(N)]
_max = 0
_min = l[0]
for t in l:
  if _max < t:
    _max = t
  if _min > t:
    _min = t  
return _max - _min

Submission status: Runtime Error

Solution code:
N = int(input())
nums = [int(input()) for i in range(N)]

print(max(nums) - min(nums))

Submission status: Runtime Error

Solution code:
from sys import stdin
data=[int(x) for x in stdin.readline().rstrip().split()]
data=sorted(data)
print(abs(data[0]-data[-1])

Submission status: Runtime Error

Solution code:
n = int(input())
li = list(input())
print(max(li)-min(li))

Submission status: Runtime Error

Solution code:
        N = int(input())
        A = input().split(" ")
        B = [int(n) for n in A]
         
        m = float("inf")
        M = 0
        for b in B:
          if b < m:
            m = b
          
          if b > M:
            M = b
         
        print(M-m)

Submission status: Runtime Error

Solution code:
    N = int(input())
    A = input().split(" ")
    B = [int(n) for n in A]
     
    m = inf
    M = 0
    for b in B:
      if b < m:
        m = b
      
      if b > M:
        M = b
     
    print(M-m)

Submission status: Runtime Error

Solution code:
N=int(input())
A=[int(x) for x in input().split()]
ans=0
for i in range(N):
  for j in range(i+1,N):
    ans=max(ans,abs(A[i]-A[j])
print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
print(max(A)-max(B))

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split))
print(max(A)- min(A))

Submission status: Runtime Error

Solution code:
def solve(string):
    n, *a = map(int, string.split())
    a = sorted(a)
    return str(abs(a[0] - a[-1]))


if __name__ == '__main__':
    print(solve([input(), input()]))

Submission status: Runtime Error

Solution code:
def solve(string):
    n, *a = map(int, string.split())
    a = sorted(a)
    return str(abs(a[0] - a[-1]))


if __name__ == '__main__':
    print(solve(input()))

Submission status: Runtime Error

Solution code:
n = int(input())
l = [int(input()) for i in range(n)]
l.sort()
print(abs(l[0]) - l[-1])

Submission status: Runtime Error

Solution code:
N=int(input())
A=[int(i) for i in input()]
maxv=A[0]
minv=A[0]
for i in range(N):
  maxv=max(maxv,A[i])
  minv=min(minv,A[i])
print(maxv-minv)

Submission status: Runtime Error

Solution code:
N=int(input())
A=[int(i) for i in input()]
maxv=A[0]
minv=A[1]-A[0]
for i in range(N):
  maxv=max(maxv,abs(A[i]-minv))
  minv=min(minv,A[i])
print(maxv)

Submission status: Runtime Error

Solution code:
N=int(input())
A=[int(i) for i in input()]
maxv=A[0]
minv=A[1]-A[0]
for i in range(N):
  maxv=max(maxv,A[i]-minv)
  minv=min(minv,A[i])
print(maxv)

Submission status: Runtime Error

Solution code:
n=int(input())

A=list(map(int,input()))



print(max(A)-min(A))

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
print(abs(max(a)-min(a))

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
print(abs(a.max()-a.min())

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    L = list(map(int, lines.pop(0).split(' ')))
    L.sort()
    print(L[-1] - L[0])

#
# main
#

# 1. use list instead of stdin

# contents = '''\
# 4
# 1 4 6 3\
# '''
# lines = contents.split('\n')

# 2. use stdin

# lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
print(a[n-1]=a[0])

Submission status: Runtime Error

Solution code:
n=input()
a=list(map(int,input().split()))
print(a.max()-a.min())

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
return max(a) - min(a)

Submission status: Runtime Error

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

print(max(a) - min(a))

Submission status: Runtime Error

Solution code:
N = int(input())

a = list(map(int,input().split())
print(abs(max(a)-min(a))

Submission status: Runtime Error

Solution code:
N = int(input())
a = map(int,raw_input().split())

amax = (max(a))
amin = (min(a))

res = abs(amax-amin)
print (res)

Submission status: Runtime Error

Solution code:
N = int(input())
a = map(int,raw_input().split())

amax = (max(a))
amin = (min(a))

res = abs(amax-amin)
print res

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=input()
a=[int(i) for i in input().split(' ')]
a.sort()
print(a[N-1]-a[0])

Submission status: Runtime Error

Solution code:
input()
lst=list(map(int,input().split())).sort()
print(lst[-1]-lst[0])

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split())).sort()
print(a[-1] - a[0])

Submission status: Runtime Error

Solution code:
input;n=list(map(itn,input().split()))
print(max(n) - min(n))

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int,input().split())
A = sorted(A)
x = A[-1]-A[0]
print(x)

Submission status: Runtime Error

Solution code:
n = int(input())
S = list(map(int,input().split())

a=soretd(S)
print(a[-1]-a[1])

Submission status: Runtime Error

Solution code:
n = int(input())
S = list(map(int,input().split())

a=soretd(S)
print(max(a)-min(a))

Submission status: Runtime Error

Solution code:
n = int(input())
A = [map(int,input().split())]
print(max(A) - min(A))

Submission status: Runtime Error

Solution code:
n = int(input())
A = [map(int,input().split())]
print(max.A - min.A)

Submission status: Runtime Error

Solution code:
a=int(input())
b=list(map(int, input().split()))
print(max(a)-min(b))

Submission status: Runtime Error

Solution code:
n=int(input())

a = [map(int, input().split())]

amin= min(a)
amax= max(a)

res= amax-amin
print(res)

Submission status: Runtime Error

Solution code:
import numpy as npo
a=input()
a=(map(int,input().split()))
a=npo.array(a)
a=npo.sort()
print(a[-1]-a[0])

print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")

Submission status: Runtime Error

Solution code:
import numpy as npo
a=input()
a=(map(int,input().split()))
a=npo.array(a)
a=npo.sort.()
print(a[-1]-a[0])

print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")

Submission status: Runtime Error

Solution code:
N = int(input())
a = map(int, input().split)

print(max(a) - min(a))

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split))

print(max(a) - min(a))

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))

asorted = sorted(A)
print(asorted[N]-asorted[0])

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))

asorted = sorted(A)
print(asorted[N+1]-asorted[0])

Submission status: Runtime Error

Solution code:
input()
a=map(int,input().split())
print(max(a)-min(a))

Submission status: Runtime Error

Solution code:
n = int(input())
A = [int(i) for i in input().split()]
A=A.sort()
print(A[-1]-A[0])

Submission status: Runtime Error

Solution code:
n = int(input())
a = map(int, input().split())
print(max(a)-min(a))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,m[111];
    cin>>N;
    for(int i=0;i<N;i++)
        cin>>m[i];
    int high = *max_element(m,m+N);
    int low = *min_element(m,m+N);
    cout<<high-low<<'\n';
    return 0;
}

Submission status: Runtime Error

Solution code:
n = int(input()) 
row = input().split()
max = row[0]
min = row[0]


    for i in range(n-1):
        if(max < row[n-1]):
            max = row[n-1]


    for i in range(n-1):
        if(min > row[n-1]):
            min = row[n-1]


print (min)

Submission status: Runtime Error

Solution code:
n = int(input()) 
row = map(int, input().split())
max = row[0]
min = 0

for i  in range(n-1):
    if(row[i] < row[i+1]):
        max = row[i+1]

for i in range(n-1):
    if(row[i] > row[i+1]):
        min = row[i+1]

print(max-min)

Submission status: Runtime Error

Solution code:
N = int(input())
A = sorted([int(input()) for _ in range(N)])

print(A[N-1] - A[0])

Submission status: Runtime Error

Solution code:
N = int(input())
l = []
for i in range(N):
    l.append(int(input()))
print(max(l)-min(l))

Submission status: Runtime Error

Solution code:
N = int(input())
p = int(input())
l=[p for i in range(N)]
print(max(l)-min(l))

Submission status: Runtime Error

Solution code:
N = int(raw_input())

A = map(int,raw_input().split())

print max(A)-min(B)

Submission status: Runtime Error

Solution code:
q=input()
a=input().split()
b=map(int,a)
maximum=max(b)
minimum=min(b)
print(maximum-minimum)

Submission status: Runtime Error

Solution code:
a=input().split()
b=map(int,a)
maximum=max(b)
minimum=min(b)
print(maximum-minimum)

Submission status: Runtime Error

Solution code:
a = int(input())
b = for list(map(int,input().split()))
min = b[0]
max = b[0]
for i in range(a):
    if b[i] < min:min=b[i]
    if b[i] > max:max=b[i]
print(max-min)

Submission status: Runtime Error

Solution code:
a = int(input)
b = map(int,input().split())
min = b[0]
max = b[0]
for i in range(a):
    if b[i] < min:min=b[i]
    if b[i] > max:max=b[i]
print(max-min)

Submission status: Runtime Error

Solution code:
N = int(input())
a = input().split()
ans = 0
min = max(a)
for i in range(0,N):
	a[i] = int(a[i])
for i in range(0,N-1):
	for j in range(1,N):
		if abs(a[i]-a[j]) < min
			min = abs(a[i]-a[j])
print(min)

Submission status: Runtime Error

Solution code:
n = input()
l = input().split()
l = map(int, l)
max, min = max(l), min(l)
print(max - min)

Submission status: Runtime Error

Solution code:
p=input;p();a=map(int,p().split());print(max(a)-min(a))

Submission status: Runtime Error

Solution code:
N = int(input())
A_list = list(map(int, input().split()))
B_list = [a - (i + 1) for i, a in enumerate(A_list)]
B_list.sort()
b = B_list[len(B_list) / 2]
s = sum([abs(B - b) for B in B_list])
print(s)

Submission status: Runtime Error

Solution code:

n = input()
l = input()
print(abs(max(l) - min(l)))

Submission status: Runtime Error

Solution code:
input()
numbers = map(int, input().split())
print(max(numbers)-min(numbers))

Submission status: Runtime Error

Solution code:
n = int(input())
n_list = list(map(int,input().split())
n_list.sort()
print(n_list[-1] - n_list[0])

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# 桁数の入力
a = input()
# スペース区切りの整数の入力
b = input().split()
b = list(map(int, b))
print(max(a) - min(a))

Submission status: Runtime Error

Solution code:
import numpy as np

a = input()
b = []
b = input().split()
ans = 0
for i in a-1:
  for j in a-1:
    c = b[i]-b[j]
    if(ans < np.abs(c):
       ans = c
print(c)

Submission status: Runtime Error

Solution code:
import sys

def solve(n, lst_a):
    a=1
    b=1    
    for i in as1:
        if a <i:
            a=i
        elif b>i:
            b=i
    return a-b

def readQuestion():
    line1 = sys.stdin.readline().rstrip()
    n = int(line1)
    line2 = sys.stdin.readline().rstrip()
    lst_a = [int(s) for s in line2.split(' ')]
    return (n, lst_a)

def main():
    n, lst_ab = readQuestion()
    answer = solve(n, lst_ab)
    print(answer)
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
input();a=map(int,input().split());print(max(a)-min(a))

Submission status: Runtime Error

Solution code:
n = int(input())
l = input().split()

max = 0
min = 100000000 

for i in range(len(l)):
    if int(l[i]) > max:
        max = int(l[i])
    if int(l[i]) < min:
        min = l[i]
            
print (abs(max-min))

Submission status: Runtime Error

Solution code:
input()
a=list(int,input().split())
print(max(a)-min(b))

Submission status: Runtime Error

Solution code:
N=input()
a=list(map(int,input().split()))
mini=maxi=a[0]
for i in range(1,N):
  mini=min(mini,a[i])
  maxi=max(maxi,a[i])
print(maxi-mini)

Submission status: Runtime Error

Solution code:
A = []

N = int(input())*N

for i in range(0, N) :
    a = int(input())
    A.append(a)
    

print(max(A) - min(A))

Submission status: Runtime Error

Solution code:
A = []

N = int(input())

for i in range(0, N) :
    a = int(input())
    A.append(a)
    

print(max(A) - min(A))

Submission status: Runtime Error

Solution code:
n = int(input())
an = input()
an = an.split()

dif = 999999999

for i in range(n-1):
    for r in range(i+1, n):
        a = int(an[i])
        b = int(an[r])

        abs = abs(a-b)
        if abs < dif:
            dif = abs

print(dif)

Submission status: Runtime Error

Solution code:
n = int(input())
an = input()
an = an.split()

dif = 10000000000

for i in range(n-1):
    for r in range(i+1, n):
        a = int(an[i])
        b = int(an[r])

        abs = abs(a-b)
        if abs < dif:
            dif = abs

print(dif)

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    print(max(A) - min(B))

Submission status: Runtime Error

Solution code:
A = []

N = int(input())
if N in range(1,100) :
    for i in range(1, N+1) :
        a = int(input())
        if a in range(1,int(10e8)) :
            A.append(a)
    
ma = max(A)
mi = min(A)

print(ma - mi)

Submission status: Runtime Error

Solution code:
N = int(input())
A = []
for i in range(1, N+1) :
    a = int(input())
    A.append(a)
print(A)

ma = max(A)
mi = min(A)

print(ma - mi)

Submission status: Runtime Error

Solution code:
N = int(input())
A = []
for i in range(1, N+1) :
    a = int(input())
    A.append(a)

ma = max(A)
mi = min(A)

print(ma - mi)

Submission status: Runtime Error

Solution code:
N=int(input())
a=[0]*N
for i in range(N):
    a[i]=int(input())
print(a)   
a_max=max(a)
a_min=min(a)
print(a_max-a_min)

Submission status: Runtime Error

Solution code:
N=int(input())
a_list=map(int,input().split())
    
a_max=max(a_list)
a_min=min(a_list)
print(a_max-a_min)

Submission status: Runtime Error

Solution code:
def main():
    N = int(input())
    A = []
    for i in range(N):
        A.append(int(input()))
    
    A.sort()
    print(A[N - 1] - A[0])
    
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N=int(input())
a_list=[int(input()) for i in range(N)]
print(a_list)
    
a_max=max(a_list)
a_min=min(a_list)
print(a_max-a_min)

Submission status: Runtime Error

Solution code:
import math
input()
x = list(map(int, input().split()))
print(math.max(x) - math.min(x))

Submission status: Runtime Error

Solution code:
n=int(input())
num=int(input().split())
print(max(num)-min(num))

Submission status: Runtime Error

Solution code:
n=int(input())
num=input().split()
print(max(num)-min(num))

Submission status: Runtime Error

Solution code:
N=int(input())
a_list=[]
for i in range(N):
    a_list.append(int(input()))
    
a_max=max(a_list)
a_min=min(a_list)
print(a_max-a_min)

Submission status: Runtime Error

Solution code:
N = int(input())

A = [i for i in input().split()]

print(max(A) - min(A))

Submission status: Runtime Error

Solution code:
N = int(raw_input())
A = map(int, raw_input().split())
m = 0
for i in range(N):
  for j in range(N):
    m = max(m, abs(A[i]-A[j])
print m

Submission status: Runtime Error

Solution code:
N = int(input())
a = np.array(list(map(int, input().split())))
print(max(a) - min(a))

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(input()) for i in range(N)]
Amin = min(A)
Amax = max(A)
print(abs(Amax-Amin))

Submission status: Runtime Error

Solution code:
N = int(input())
A = map(int,input().split())
print(max(A)-min(A))

Submission status: Runtime Error

Solution code:
n=int(input())
num=input.split()
print(num.max()-num.min())

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
a.sort()
print(a[-1] - a[0])

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(num) for num in input().split()]
m = 0
for i in range(n):
  for j in range(n):
    m = max(max,abs(a[i]-a[j]))
print(m)

Submission status: Runtime Error

Solution code:
def main():
    N = int(input())
    A = []
    for i in range(N):
        A.append(int(input()))
    
    A.sort()
    print(A[n - 1] - A[0])
    
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def main():
	N = int(input())
	seq = list(map(int, input().split()))
	maks = 0
	for i in range(1, N):
		maks = max(seq[i] - seq[i - 1])
	print(maks)
	return 0
main()

Submission status: Runtime Error

Solution code:
input()
n=sorted(list(map(int,input().split())))
print(n［-1］- n［0］)

Submission status: Runtime Error

Solution code:
n = int(input())
a = map(int, input().split())

mn = 10 ** 9
mx = 0

for i in range(n):
  if a[i] < mn:
    mn = a[i]
    
  if a[i] > mx:
    mx = a[i]

print(mx - mn)

Submission status: Runtime Error

Solution code:
N = int(input().strip())
A = map(int, input().strip().split())
max_abs_sum = 0
for i in range(len(A) - 1):
  for j in (i+1, range(A)):
    if max_abs_sum < abs(A[i] - A[j]):
      max_abs_sum = abs(A[i] - A[j])
print(max_abs_sum)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
b = a.sort()
print(abs(b[0] - b[-1]))