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: Accepted

Solution code:
n=int(input())
b=[]
a=list(map(int,input().split()))
for i in range(len(a)):
        for j in range(len(a)-1):
                if i!=j:
                        b.append(abs(a[i]-a[j]))
print(max(b))

Submission status: Accepted

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

mn = 10**9+1 # 数列Aの最小値
mx = 0       # 数列Aの最大値

for v in A:
  if v < mn:
    mn = v   # 最小値を更新
  if v > mx:
    mx = v   # 最大値を更新

print(mx-mn)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = -1
for i in range(N):
  for j in range(N):
    diff = abs(A[i]-A[j])
    if diff > ans:
      ans = diff
print(ans)

Submission status: Accepted

Solution code:
input()

a = list(map(int,input().split()))

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

Submission status: Accepted

Solution code:
n = int(input())

a = list(map(int,input().split()))

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

Submission status: Accepted

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("\n".join([input(), input()])))

Submission status: Accepted

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

for i in range(N):
  A[i] = int(A[i])
A.sort()
print(A[-1] - A[0])

Submission status: Accepted

Solution code:
#ABC102 B
#N個の整数の集合Aが与えられる。Aのうち差の絶対値がもっとも大きいものの差を求めよ
N = int(input())
A = list(map(int, input().split(' ')))
print(max(A)-min(A))

Submission status: Accepted

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

A.sort()
print(A[-1] - A[0])

Submission status: Accepted

Solution code:
input()
l=list(map(int, input().split()))
import itertools
print(max(abs(x-y) for x,y in itertools.combinations(l, 2)))

Submission status: Accepted

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

aList = sorted(aList)
print(aList[-1]-aList[0])

Submission status: Accepted

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

print(a[-1] - a[0])

Submission status: Accepted

Solution code:
# coding: utf-8
_ = input()
N = sorted(list(map(int, input().split())))
print(N[-1] - N[0])

Submission status: Accepted

Solution code:
def maximum_difference(N: int, A: list)->int:
    return max(A) - min(A)


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    ans = maximum_difference(N, A)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(int(x) for x in input().split())
print(max(A) - min(A))

Submission status: Accepted

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

sortedA = sorted(A)

answer = sortedA[-1] - sortedA[0]

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

Submission status: Accepted

Solution code:
_ = input()
As = [int(i) for i in input().split()]

print(max(As)-min(As))

Submission status: Accepted

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

print(max(A_list) - min(A_list))

Submission status: Accepted

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

A = sorted(A)
print(A[len(A)-1]-A[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc102/tasks/abc102_b
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
print(max(a) - min(a))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#102B

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

answer = abs(max(a)-min(a))

print(answer)

Submission status: Accepted

Solution code:
N = int(input())
A_list = list(map(int, input().split()))
a = max(A_list)
diff = 0
for i in A_list:
	b = abs(a - i)
	if b > diff:
		diff = b
print(diff)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
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: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 26 23:53:42 2019

@author: yuta
"""

def maxdif(n,a):
    b = sorted(list(map(int,a)))
    c = b[n-1] - b[0]
    print(c)

x = int(input())
y = input().split()

maxdif(x,y)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        for j in range(i, N):
            dif = abs(A[i] - A[j])
            if dif > ans:
                ans = dif
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

print max(A)-min(A)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import*;n,*a=map(int,open(0).read().split());print(max(abs(i[0]-i[1])for i in combinations(a,2)))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
max_n = A[0]
min_n = A[0]
for i in range(N):
    if max_n < A[i]:
        max_n = A[i]
    if min_n > A[i]:
        min_n = A[i]
print(max_n - min_n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
print(max(a) - min(a))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

def main():
  input = sys.stdin.readline
  N = int(input())
  A = list(map(int, input().split()))
  a, b = min(A), max(A)
  print(b-a)


if __name__ == '__main__':
  main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main() -> None:
    N = int(input())
    A = list(map(int, input().split()))
    AS = sorted(A)
    print(abs(AS[0] - AS[-1]))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(max(list)-min(list))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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



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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
int_n = int(input())

ar_in = list(map(int, input().split()))

print(abs(max(ar_in)) - abs(min(ar_in)))

Submission status: Accepted

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

a.sort()

print(a[-1] - a[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
As = list(map(int, input().split()))
print(max(As) - min(As))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
l = []
for i in range(len(a)):
    for j in range(i,len(a)):
        l.append(abs(a[i]-a[j]))
print(max(l))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


A.sort()
result = A[len(A)-1] - A[0]
print(abs(result))

Submission status: Accepted

Solution code:
N = int(input())

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

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

print(ma - mi)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 12 15:50:41 2019

@author: shinjisu
"""


import math


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def dmp(x):
    global debug
    if debug:
        print(x)


# ABC 100 B Ringo's Favorite Numbers
def abc100b():
    D, N = getIntList()
    if N % 100 == 0:
        return (N+1) * 100**D  # WA N==100のとき正しくない 101*100**D
    else:
        return N * 100**D


# ABC 101 B digit sum
def abc101b():
    N = getInt()
    sm = 0
    n = N
    while n > 0:
        sm += n % 10
        n //= 10
    if N % sm == 0:
        return 'Yes'
    else:
        return 'No'


# ABC 102 B Maximum Difference
def abc102b():
    N = getInt()
    A = getIntList()
    return max(A) - min(A)


debug = False  # True False
print(abc102b())

Submission status: Accepted

Solution code:
n=input().split()
a=[abs(int(z)) for z in input().split()]
print(max(a)-min(a))

Submission status: Accepted

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

ans = 0
for i in range(N):
    for j in range(i+1, N):
        ans = max(ans, abs(As[i]-As[j]))
print(ans)

Submission status: Accepted

Solution code:
n =int(input())
a = list(int(i) for i in input().split())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

x = ip()                              #入力整数1つ
#x,y= (int(i) for i in input().split())      #入力整数横2つ
#x,y,z = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
a = [int(i) for i in input().split()]        #入力整数配列
#s = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

#jの変数はしようできないので注意

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

Submission status: Accepted

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


main()

Submission status: Accepted

Solution code:
N = int(input())
A = sorted([int(n) for n in input().split()])

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

Submission status: Accepted

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

print(max(li) - min(li))

Submission status: Accepted

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

res = 0
for i in range(N):
    for j in range(i + 1, N):
        res = max(res, abs(a[i] - a[j]))
print(res)

Submission status: Accepted

Solution code:
N=input()
a=[int(i) for i in input().split()]
print(abs(max(a)-min(a)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    l = [int(i) for i in input().split()]
    print(max(l) - min(l))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
""" AtCoder """

import sys
input = sys.stdin.readline
 
N = int(input())

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

A.sort()

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

def main():
    N = int(input())
    A = list(map(int, input().split()))

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
alist = [int(x) for x in input().split()]
print(abs(max(alist) - min(alist)))

Submission status: Accepted

Solution code:
n = int(input())
A = [int(i) for i in input().split()]

ans = -1
for i in range(n):
    for j in range(n):
        temp = abs(A[i] - A[j])
        ans = max(ans, temp)
        
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
s = []
for i in range(n):
    for j in range(n):
        s.append(a[i]-a[j])
print(max(s))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = [i for i in map(int, str(input()).split())]
print(max(A) - min(A))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Maximum Difference
import sys

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

res = [0 for _ in range(N*N)]
cnt = 0
for i in range(N) :
    for j in range(N) :
        res[cnt] = abs(A[i] - A[j])
        cnt += 1

print(max(res))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input()
a=[int(_) for _ in input().split()]
print(max(a)-min(a))

Submission status: Accepted

Solution code:
N=int(input())
A=input().strip().split(" ")
A=[int(i) for i in A]
A.sort()

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

Submission status: Accepted

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

dist = max(A_list)-min(A_list)
print(dist)

Submission status: Accepted

Solution code:
# coding: utf-8
_ = input()
lst = list(map(int, input().split()))
print(max(lst) - min(lst))

Submission status: Accepted

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

a = max(A)
b = min(A)

print(abs(a - b))

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
print(max(A) - min(A))

Submission status: Accepted

Solution code:
N = int(input())
num = [int(j) for j in input().split()]
max = min = num[0]

for i in range(N):
    if max < num[i]:
        max = num[i]
    if min > num[i]:
        min = num[i]

print(max - min)

Submission status: Accepted

Solution code:
N = int(input())
A = input().split(" ")
A = [int(i) for i in A]
A = sorted(A)

if A[0] != A[N-1]:
    print(A[N-1] - A[0])
else:
    print(0)

Submission status: Accepted

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


def main():
    """Function."""
    n = int(input())
    a = list(map(int, input().split()))

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#B Maximum Difference
a = int(input())
x = list(map(int,input().split()))
x.sort()
print(x[a-1]-x[0])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a = int(input())

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

B = []

for i in A:
    B.append(i)

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A_list = [int(a) for a in input().split()]
list = []
for j in range(N):
    for k in range(N):
        list.append(abs(A_list[j]-A_list[k]))
print(max(list))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
a = list(map(int,input().split()))
print(max(a)-min(a))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
A = map(int,list(raw_input().split()))
Max = 0
Min = A[0]
for i in range(N):
  if Max <=A[i]:
    Max = A[i]
  if Min >= A[i]:
    Min = A[i]
print Max-Min

Submission status: Accepted

Solution code:
N = input()
A = map(int,list(raw_input().split()))
AA=sorted(A,reverse=True)
print AA[0]-AA[-1]

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

a = list(map(int,input().split()))

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

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

Submission status: Accepted

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest102-B
#  https://beta.atcoder.jp/contests/abc102/tasks/abc102_b

def maxDiff(str) :
	numList = list(map(int, str.split()))
	numList.sort()
	maxdiffint = numList[-1]-numList[0]
	ans = maxdiffint
	return ans


if __name__ == '__main__':
	_ = input()
	inputStr = input()
	ans=maxDiff(inputStr)
	print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
def abc102_b():
    _ = int(input())
    a = list(map(int,input().split()))

    return max(a) - min(a)


print(abc102_b())

Submission status: Accepted

Solution code:
N = int(input())
li = [int(i) for i in input().split()]

print(max(li) - min(li))

Submission status: Accepted

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

Submission status: Accepted

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

idx_of_min = idx_of_max = 0
for i in range(n):
    if a[i] < a[idx_of_min]:
        idx_of_min = i
    if a[i] > a[idx_of_max]:
        idx_of_max = i

print(a[idx_of_max] - a[idx_of_min])

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    nums = input().split()
    for i in range(len(nums)):
        nums[i] = int(nums[i])
    max_diff = 0
    for i in range(len(nums)):
        for j in range(i, len(nums)):
            diff = abs(nums[i] - nums[j])
            if diff > max_diff:
                max_diff = diff
    print(max_diff)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
l = []
for i in range(len(a)-1):
    for j in range(i, len(a)):
        l.append(abs(a[i]-a[j]))
print(max(l))

Submission status: Accepted

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

idx_of_min, idx_of_max = 0, 0
for i in range(n):
    if a[i] < a[idx_of_min]:
        idx_of_min = i
    if a[i] > a[idx_of_max]:
        idx_of_max = i

print(a[idx_of_max] - a[idx_of_min])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
an = [int(i) for i in input().split()]
print(max(an)-min(an))

Submission status: Accepted

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

idx_of_min = 0
idx_of_max = 0
for i, a_i in enumerate(a):
    if a_i < a[idx_of_min]:
        idx_of_min = i
    if a_i > a[idx_of_max]:
        idx_of_max = i

print(a[idx_of_max] - a[idx_of_min])

Submission status: Accepted

Solution code:
a = int(input())
s = list(map(int,input().split()))
r = sorted(s)
c = abs(r[a-1]-r[0])
print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A_list = [int(i) for i in input().split()]

A_max = max(A_list)
A_min = min(A_list)
ans = abs(A_max - A_min)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

n = int(input())
A = list(map(int, input().split()))
print(max(A) - min(A))

Submission status: Accepted

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


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

a.sort()
print(abs(a[0] - a[n-1]))

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int,input().split()))
L = sorted(L)
ans = abs(L[-1]-L[0])
print(ans)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())
print(max(a) - min(a))

Submission status: Accepted

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

print(max(As)-min(As))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

print(max(b)-min(b))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = input().split()
a = [int(m) for m in a]

x = max(a)
y = min(a)

print(x - y)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Max = 0
Min = 10 ** 9

for i in range(n):
    if int(a[i]) > Max:
        Max = int(a[i])
    if int(a[i]) < Min:
           Min = int(a[i])

print(Max - Min)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

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

max_answer = 0

for i in range(N):
    for j in range(i + 1, N):
        answer = abs(A[i] - A[j])
        if answer > max_answer:
            max_answer = answer

print(max_answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
i=input;i();l=sorted(map(int,i().split()));print(l[-1]-l[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
i=input
i()
l=sorted(map(int,i().split()))
print(l[-1]-l[0])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input()
a=[abs(int(i))for i in input().split()]
print(max(a)-min(a))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin


def main() -> None:
    n = next_int()
    mx = mn = 0

    for i in range(n):
        ai = next_int()
        if i == 0:
            mx = mn = ai
        else:
            mx = max(mx, ai)
            mn = min(mn, ai)

    print(mx - mn)


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int, input().split()))
mn=1e9
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: Accepted

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

a.sort()
print(a[len(a)-1]-a[0])

Submission status: Accepted

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

L.sort()

print(abs(L[0]-L[-1]))

Submission status: Accepted

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

nums.sort()
max = nums[-1]
min = nums[0]
tmp = abs(max-min)
for i in range(len(nums)):
  if tmp < abs(max - nums[i]):
    tmp = abs(max - nums[i])

print(tmp)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Maximum Difference
input()
print((lambda x: x[-1]-x[0])(sorted(list(map(int, input().split())))))

Submission status: Accepted

Solution code:
import numpy as np

count = int(input())

array_1 = list(map(int, input().split()))

print(max(array_1) - min(array_1))

Submission status: Accepted

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

Submission status: Accepted

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