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-----
4
1 4 6 3

-----Sample Output-----
5

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

Difficulty: introductory

Starter code:

Solutions:
# coding: utf-8
# Your code here!
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(i+1,n):
        ans=max(abs(a[i]-a[j]),ans)
print(ans)

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

max = 0
min = 1000000000

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

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

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

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

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

ans = 0
for i in range(N):
    for j in range(N):
        if i==j: continue
        ans = max(ans, abs(A[i] - A[j]))

print(ans)

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

difference = max(A) - min(A)

print(difference)

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

N = int(input())
S = map(int,input().split())

Number = list(S)

Maxi = max(Number)
Mini = min(Number)

print(Maxi - Mini)

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

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

import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

a = k()
b = l()
b.sort()

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

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

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

ans = 0
for i in range(n):
    for j in range(n):
        if i == j: continue
        ans = max(ans, abs(A[i]-A[j]))
print(ans)

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

n = int(input())
li = list(map(int,input().split()))
li.sort()
print(abs(li[-1]-li[0]))

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

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

n = int(input())
a = list(map(int, input().split()))
max = 0
for i in range(n):
  for j in range(i+1, n):
    if abs(a[j] - a[i]) > max:
      max = abs(a[j] - a[i])
print(max)

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

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

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


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

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

N=int(input())
A=[int(a) for a in input().split()]
lists=[abs(A[i]-A[j]) for i in range(N) for j in range(N)]
print(max(lists))

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

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

#ABC102B
n = int(input())
a = sorted(list(map(int,input().split())))
print(a[-1]-a[0])

N = int(input())
lst = input().split()

for i in range(N):
   lst[i] = int(lst[i])

print(abs(max(lst) - min(lst)))

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

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

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

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

ans = max(A) - min(A)

print(ans)

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

answer = (max(num_list) - min(num_list))

print(answer)




n = int(input())
min_A = 10**9+7
max_A = -1
for i in input().split():
  tmp = int(i)
  max_A = max(tmp,max_A)
  min_A = min(min_A,tmp)
  
print((abs(max_A-min_A)))


def mapt(fn, *args):
    return list(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    n = int(input())
    a = Input()
    print(max(a) - min(a))


main()

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

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

num_len = int(input())
numbers = list(map(int, input().split()))
print(max(numbers) - min(numbers))

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

print(max(A1)-min(A1))

# B - Maximum Difference

# N
N = int(input())
my_list = list(map(int, input().split(maxsplit=N)))

my_list_sort = sorted(my_list, reverse=True)
answer = my_list_sort[0] - my_list_sort[-1]

print(answer)


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



# -*- coding: utf-8 -*-
# モジュールのインポート
import itertools


def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    N = int(input())
    A = list(map(int, input().split()))

    return N, A


def main(A: list) -> None:
    """
    メイン処理.

    Args:\n
        A (list): 整数列(1 <= A_i <= 10^9)
    """
    # 求解処理
    ans = 0
    for A_i, A_j in itertools.combinations(A, r=2):
        ans = max(ans, abs(A_i - A_j))

    # 結果出力
    print(ans)


def __starting_point():
    # 標準入力を取得
    N, A = get_input()

    # メイン処理
    main(A)

__starting_point()

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

import itertools
N = int(input())
A = map(int,input().split())
score=0
for i,j in list(itertools.combinations(A,2)):
  if score < abs(i-j):score=abs(i-j)
print(score)

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

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

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

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

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

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

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

n = input()
d = list(map(int, input().split()))

print(max(d) - min(d))

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

def answer(n: int, a: list) -> int:
    return max(a) - min(a)
print((answer(n, a)))


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

n = int(input())
numbers = list(map(int, input().split()))

print((max(numbers) - min(numbers)))


n = int(input())
al = sorted(list(map(int, input().split())))
print(abs(al[0]-al[-1]))

S_list = [input() for i in range(2)]
N = map(int,S_list[0].split())    
A_list = list(map(int,S_list[1].split()))

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

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

diffmax = 0
for i in range(N):
	for j in range(1,N):
		diff = abs(A[i]-A[j])
		if diff > diffmax:
			diffmax = diff
print(diffmax)

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

import sys

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

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

import sys

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

A.sort()

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

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

# 102b

def atc_102b(N: int, Ai_input: str) -> int:
    Ai = [int(i) for i in Ai_input.split(" ")]
    return max(Ai) - min(Ai)

N_input_value = int(input())
Ai_input_value = input()
print(atc_102b(N_input_value, Ai_input_value))

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

Amax = max(A)
Amin = min(A)

ans = Amax - Amin
print(ans)

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

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

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

total_integer = int(input())
integer = sorted(list(map(int, input().split())))
print(integer[total_integer - 1] - integer[0])

n = int(input())
al = sorted(list(map(int, input().split())))
print((abs(al[-1]-al[0])))



N = int(input())
a_list = list(map(int, input().split()))
max_ = abs(max(a_list) - min(a_list))
print(max_)

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

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

# 長さNの整数列Aが与えられます。Aの（添字の）異なる2要素の差の絶対値の最大値を求めてください。

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

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

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

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

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

_, a = input(), list(sorted(list(map(int, input().split()))))
print((a[len(a) - 1] - a[0]))


#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
# mod = 9982443453
# mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n = I()
A = readInts()
ans = -1
for i in range(n-1):
    for j in range(i+1, n):
        ans = max(ans, abs(A[i]-A[j]))
print(ans)


# 入れ子で引き算、setでかぶりを消して、sorted,reverseで降順にし、0番を出す
N = int(input())
A = list(map(int, input().split()))
sub = []

for i in A:
    for j in A:
        sub.append(abs(i - j))

descending_sub = sorted(set(sub), reverse=True)
# print(descending_sub)

print((descending_sub[0]))


def diff_list_max(l: list) -> int:
    return abs(max(l) - min(l))


def __starting_point():
    n = int(input())
    l = list(map(int, input().split()))
    print((diff_list_max(l)))

__starting_point()

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

N = int(input())
nums = [int(s) for s in input().split()]

ans=max(nums)-min(nums)
print(ans)

# -*- coding: utf-8 -*-

def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    N = int(input())
    A = list(map(int, input().split()))

    return N, A


def main(A: list) -> None:
    """
    メイン処理.

    Args:\n
        A (list): 整数列(1 <= A_i <= 10^9)
    """
    # 求解処理
    ans = max(A) - min(A)

    # 結果出力
    print(ans)


def __starting_point():
    # 標準入力を取得
    N, A = get_input()

    # メイン処理
    main(A)

__starting_point()

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

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

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

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

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



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


ma=a.index(max(a))
mi=a.index(min(a))

print((a[ma]-a[mi]))


n=int(input()) #Nを入力
lista=input().split() #Aを入力
p=int(lista[0])#p最小値
q=int(lista[0])#q最大値
for i in range(1,n):
    k=int(lista[i])
    if k<=p:
        p=k
    elif k>=q:
        q=k
print(int(q-p))

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

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

# Aの（添字の）異なる2要素の差の絶対値の最大値を出力せよ。

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

# -*- coding: utf-8 -*-
# モジュールのインポート
import itertools

# 標準入力を取得
N = int(input())
A = list(map(int, input().split()))

# 求解処理
ans = 0
for A_i, A_j in itertools.combinations(A, r=2):
    ans = max(ans, abs(A_i - A_j))

# 結果出力
print(ans)


N, *A = list(map(int, open(0).read().split()))
mx, mn = 0, 1_000_000_000
for a in A:
    mx = max(mx, a)
    mn = min(mn, a)
print((mx - mn))


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

tmp_max = max(a)
tmp_min = min(a)

ans = tmp_max - tmp_min

print(ans)

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

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

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

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

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

answer=max(a)-min(a)

print(answer)

a=input()
b=input().split()
b=[int(i) for i in b]
print(int(max(b))-int(min(b)))

N = int(input())
l = [int(i) for i in input().split()]
m = []
for i in range(N):
    for j in range(i):
        m.append(abs(l[i] - l[j]))
print(max(m))

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

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

n = int(input())
list01 = input().split()
list02 = [int(a) for a in list01]
print(max(list02) - min(list02))

N=int(input())
A=list(map(int, input().split()))
ans=0
for i in range(N):
    for j in range(N):
        if i==j: continue
        ans = max(ans, abs(A[i]-A[j]))
print(ans)

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

result = 0;

for i in Nums:
    for ii in Nums:
        if result < abs(i - ii):
            result = abs(i - ii)
print(result)

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

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

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

n = int(input())
num = list(map(int,input().split()))
ans = 0

for i in range(n):
  for j in range(i,n):
    num1 = abs(num[i]-num[j])
    if ans <= num1:
      ans = num1
print(ans)