Problem:

集会所

　

イヅア村の住民は村に集会所を建てることにしました。この村では東西に一直線に伸びる道路に沿って建物を建てられる地点が決まっています。最も西の地点を０番目の地点として、そこから等間隔に東に向かって１番目、２番目、…と地点番号が与えられています。村人の家と集会所を建てることができるのは、これらの地点だけです。各家には１人以上の村人が住んでいます。どの村人も隣の地点まで１分間で移動できます。

  集会を開くのに便利なように、ある時刻に一斉に全ての村人が自分の家から集会所に向かったとき、全員が集まるのに必要な時間が最小になるような場所に、集会所を建てることにしました。
 

家の建っている地点の番号が与えられたときに、全ての村人が集会所に集まるのに必要な時間の最小値を計算するプログラムを作成せよ。ただし、集会所の地点番号が家の地点番号と重複してもよいものとする。

入力

  入力は以下の形式で与えられる。

$N$
$x_1$ $x_2$ ... $x_N$

  １行目に家の数$N$ ($1 \leq N \leq 1000$)が与えられる。２行目に家の建っている地点番号$x_i$ ($0 \leq x_i \leq 2000$)が与えられる。ただし、家の地点番号は全て異なる($i \ne j$について$x_i \ne x_j$である)。

出力

集会所に集まるのに必要な最小の時間を分単位で１行に出力する。

入出力例

入力例１

3
4 0 1

出力例１

2

入力例２

2
1 2

出力例２

1



Sample input:
3
4 0 1


Sample output:
2

Submission status: Accepted

Solution code:
import math
N = int(input())
A = list(map(int, input().split()))
m = min(A)
M = max(A)
print(math.ceil((m + M) / 2) - m)

Submission status: Accepted

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

s=max(x)-min(x)
if s%2==0:
    print(int(s/2))
elif s==1:
    print(1)
else:
    print(int(s/2)+1)

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int,input().split()))
if (max(a)-min(a))%2 == 0:
    print((max(a)-min(a))//2)
else:
    print(((max(a)-min(a))//2)+1)

Submission status: Accepted

Solution code:
n=int(input())
x=list(map(int,input().split()))
mi=(max(x)+min(x))//2
print(max(x)-mi)

Submission status: Accepted

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

c=max(b)
d=min(b)

if (c-d)%2==0:
    print((c-d)//2)
else:
    print((c-d+1)//2)

Submission status: Accepted

Solution code:

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

if x==1:
    print(0)
else:
    a=sorted(list)
    b=a[0]
    c=a[-1]
    if c-b==1:
        print(1)
    elif b==0:
        if c%2!=0:
            print(c//2+1)
        else:
            print(c//2)
    elif (c-b)%2!=0:
        print((c-b)//2+1)
    else:
        print((c-b)//2)

Submission status: Accepted

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


if (A[-1]-A[0])%2==1:
    print((A[-1]-A[0]+1)//2)
else:
    print((A[-1]-A[0])//2)

Submission status: Accepted

Solution code:
N = int(input())
x = list(map(int, input().split()))
max = max(x)
min = min(x)
if (max - min) % 2 == 0:
    print((max - min) // 2)
else:
    print(((max - min) + 1) // 2)

Submission status: Accepted

Solution code:
import math
N = int(input())
b=[]
a = list(map(int,input().split()))
#print('@',a)

x = (min(a)+max(a))//2

#if (min(a)+max(a))%2 == 0:
for i in range(N):
    b.append(abs(x-a[i]))
print("{:.0f}".format(max(b)))

#else:

Submission status: Accepted

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

s=max(a)-min(a)

if s==1:
    print("1")
else:
    if s%2==0:
        print(int(s/2))
        
    else:
        print(int((s/2)+1))

Submission status: Accepted

Solution code:
import math
a = int(input())
b = list(map(int, input().split()))
c = min(b)
d = max(b)
print(math.ceil((c+d)/2)-c)

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int,input().split()))
m = min(a)
M = max(a)
k = M-m
if k%2 != 0:
    k+=1
k/=2
print(f'{k:1.0f}')

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=max(a)-min(a)
if b%2:
    b=b+1
    print(b//2)
else:
    print(b//2)

Submission status: Accepted

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

minX = 9999
maxX = -1

for i in range(N):
    minX = min(minX, x[i])
    maxX = max(maxX, x[i])
    
print((maxX-minX+1)//2)

Submission status: Accepted

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

if x==1:
    print(0)
else:
    a=sorted(list)
    b=a[0]
    c=a[-1]
    if c-b==1:
        print(1)
    elif b==0:
        if c%2!=0:
            print(c//2+1)
        else:
            print(c//2)
    elif (c-b)%2!=0:
        print((c-b)//2+1)
    else:
        print((c-b)//2)

Submission status: Accepted

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

l=max(lst)-min(lst)
if l==1:
    print(1)
elif l%2==0:
    print(int(l/2))
else:
    print(int((l+1)/2))

Submission status: Accepted

Solution code:
N=int(input())

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

a= max(x) - min(x) +1

print(a//2)

Submission status: Accepted

Solution code:
import math
A = int(input())
B = list(map(int,input().split()))
m = min(B)
M = max(B)
print(math.ceil((m + M) / 2) - m)

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int,input().split()))
min = min(x)
max = max(x)
p = (max + min) // 2
print(max - p)

Submission status: Accepted

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

S = max(A)-min(A)

if S%2 == 0:
    print(S//2)
else:
    print(S//2+1)

Submission status: Accepted

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

b = (max(a) - min(a)) / 2
c =(math.ceil(b))
print(c)

Submission status: Accepted

Solution code:
import math
n=int(input())
x=list(map(int,input().split()))
s=max(x)
t=min(x)
d=abs(s-t)
print(math.ceil(d/2))

Submission status: Accepted

Solution code:
#(46)集会所
n=int(input())
l=list(map(int,input().split()))
a=max(l)
b=min(l)
c=(a+b+1)//2
print(abs(b-c))

Submission status: Accepted

Solution code:
N = int(input())
X = list((int(x) for x in input().split()))
X.sort()

if (X[N - 1] - X[0]) % 2 == 0:
    print(round((X[N - 1] - X[0]) / 2))
else:
    print(round(((X[N - 1] - X[0]) + 1) / 2))

Submission status: Accepted

Solution code:
import math
N = int(input())
A = list(map(int, input().split()))
m = min(A)
M = max(A)
print(math.ceil((m + M) / 2) - m)

Submission status: Accepted

Solution code:
import math
n=int(input())
a=list(map(int, input().split()))
mn=min(a)
mx=max(a)
print(math.ceil((mn+mx)/2)-mn)

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int, input().split()))
if (max(x)-min(x))%2 == 0:
    print((max(x)-min(x))//2)
else:
    print((max(x)-min(x))//2+1)

Submission status: Accepted

Solution code:
import math
N = int(input())
A = list(map(int,input().split()))
m = min(A)
M = max(A)
print(math.ceil((m + M) / 2) - m)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
if (max(a)-min(a)) % 2 == 0:
    print((max(a)-min(a))//2)
else:
    print((max(a)-min(a))//2+1)

Submission status: Accepted

Solution code:
a = int(input())
b = list(map(int,input().split()))
b = sorted(b)
c = b[-1]-b[0]
if c%2 == 1:
    print((c+1)//2)
else :
    print(c//2)

Submission status: Accepted

Solution code:
import math
N=int(input())
M=list(map(int,input().split()))

a=max(M)
b=min(M)

print(math.ceil((a+b)/2)-b)

Submission status: Accepted

Solution code:
import math
N=int(input())
a=list(map(int, input().split()))
m=min(a)
M=max(a)
print(math.ceil((m+M)/2)-m)

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int,input().split()))
m = abs(max(x) - min(x))
if m % 2:
  m = m + 1
  print(m // 2)
else:
  print(m // 2)

Submission status: Accepted

Solution code:
import math
N=int(input())
A=list(map(int, input().split()))
m=min(A)
M=max(A)
print(math.ceil((m+M)/2)-m)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
x=list(map(int,input().split()))

if (max(x)-min(x))%2==0:
    print((max(x)-min(x))//2)
else:
    print((max(x)-min(x))//2+1)

Submission status: Accepted

Solution code:
n=int(input())
s=list(map(int,input().split()))
a=max(s)-min(s)
if a==1:
    print(1)
else:
    if a%2==0:
        print(a//2)
    else:
        print(a//2+1)

Submission status: Accepted

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

s = (max(house)+min(house))//2

print(max(house)-s)

Submission status: Accepted

Solution code:
N=int(input())
a = list(map(int,input().split()))
a.sort()
A=(max(a)-min(a)+1)//2
print(A)

Submission status: Accepted

Solution code:
N = int(input())
X = list((int(x) for x in input().split()))
X.sort()

if (X[N - 1] - X[0]) % 2 == 0:
    print(round((X[N - 1] - X[0]) / 2))
else:
    print(round(((X[N - 1] - X[0]) + 1) / 2))

Submission status: Accepted

Solution code:
n=int(input())
x=list(map(int,input().split()))
if (max(x)+min(x)+1)%2 != 0:
    print((max(x)+min(x)+1)//2-min(x))
else:
    print((max(x)+min(x)+1)//2-min(x))

Submission status: Accepted

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

if (max(x)+min(x)+1)%2 != 0:
    print((max(x)+min(x)+1)//2-min(x))
    
else:
    print((max(x)+min(x)+1)//2-min(x))

Submission status: Accepted

Solution code:
n=int(input())
x=list(map(int,input().split()))
s=max(x)-min(x)
if s%2==0:
    print(int(s/2))
else:
    print(int((s+1)/2))

Submission status: Accepted

Solution code:
import math
n = int(input())
a = list(map(int, input().split()))
x = max(a)
y = min(a)
print(math.ceil((x+y)/2)-y)

Submission status: Accepted

Solution code:
a = int(input())
b = list(map(int,input().split()))
c = abs(max(b) - min(b))
if c % 2:
  c = c + 1
  print(c // 2)
else:
  print(c // 2)

Submission status: Accepted

Solution code:
N = int(input())
x = list(map(int, input().split()))
xmin, xmax = min(x), max(x)
temp = []
res = xmax-xmin
for i in range(xmin, xmax+1):
	for n in range(N):
		temp.append(abs(x[n]-i))
	if max(temp)<res:
		res = max(temp)
	temp=[]

print(res)

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int, input().split()))
xa=min(x)
xb=max(x)
X=xa+xb
if X%2==0:
    print(xb-X//2)
else:
    print((X+1)//2-xa)

Submission status: Accepted

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

min=10000
for j in range(2001):
    dis=[]
    for i in range(n):
        dis.append(abs(house[i]-j))
    a=max(dis)
    #print(a)
    if min>a:
        min=a
    else:
        pass
print(min)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
m = abs(max(a)-min(a))
if m % 2:
  m = m + 1
  print(m // 2)
else:
  print(m // 2)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Accepted

Solution code:
N=int(input())
x=list(map(int,input().split()))
x.sort()
d=int(x[N-1]-x[0])
if d%2==0:
    print(d//2)
else:
    print((d+1)//2)

Submission status: Accepted

Solution code:
import math
n=int(input())
a=list(map(int,input().split()))
A=max(a)
B=min(a)
C=(math.ceil((A+B)/2))
if abs(A-C) > abs(B-C):
    print(abs(A-C))
elif abs(A-C) < abs(B-C):
    print(abs(B-C))
else:
    print(abs(A-C))

Submission status: Accepted

Solution code:
N=int(input())
x=list(map(int,input().split()))
a=(max(x)-min(x)+1)//2
print(a)

Submission status: Accepted

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

if (s-t)%2==0:
    print((s-t)//2)
else:
    print((s-t+1)//2)

Submission status: Accepted

Solution code:
n=int(input())
x=list(map(int,input().split()))
s=max(x)-min(x)
if s%2==0:
    print(int(int(s/2)))
else:
    print(int((s+1)/2))

Submission status: Accepted

Solution code:
N=int(input())
x = list(map(int, input().split()))
a=min(x)
b=max(x)
print((b-a+1)//2)

Submission status: Accepted

Solution code:
a=int(input())
lst=list(map(int,input().split()))
b=max(lst)
c=min(lst)
d=(b-c)//2
if (b-c)%2==0:
    print(d)
else:
    print(d+1)

Submission status: Accepted

Solution code:
a=int(input())
M=list(map(int,input().split()))
b=max(M)
c=min(M)
d=(b-c)//2
if (b-c)%2==0:
    print(d)
else:
    print(d+1)

Submission status: Accepted

Solution code:
N=int(input())
n=list(map(int,input().split()))
kyori=max(n)-min(n)
if kyori==1:
    print('1')
else:
    if kyori%2==0:
        print(int(kyori/2))
    else:
        print(int((kyori+1)/2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
x=list(map(int,input().split()))
s=max(x)-min(x)
if s%2==0:
    print(int(s/2))
else:
    print(int((s+1)/2))

Submission status: Accepted

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

print(max(a)-(max(a)+min(a))//2)

Submission status: Accepted

Solution code:
a=int(input())
L=list(map(int,input().split()))
b=max(L)
c=min(L)
d=(b-c)//2
if (b-c)%2==0:
    print(d)
else:
    print(d+1)

Submission status: Accepted

Solution code:
n=int(input())
x =list(map(int,input().split()))
print((max(x)-min(x)+1)//2)

Submission status: Accepted

Solution code:
import math
h=int(input())
p=list(map(int,input().split()))
print(math.ceil((max(p)-min(p))/2))

Submission status: Accepted

Solution code:
n=int(input())
l=[]
l=list(map(int,input().split()))
l.sort()
a=max(l)
b=min(l)
if (a-b)%2==0:
    print(int((a-b)/2))
else:
    print(int((a-b+1)/2))

Submission status: Accepted

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

c=max(b)
d=min(b)

if (c-d)%2==0:
    print((c-d)//2)
else:
    print((c-d+1)//2)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
a=max(l)
b=min(l)
c=(a+b+1)//2
print(abs(b-c))

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
if (max(a)-min(a))%2==0:
    print((max(a)-min(a))//2)
else:
    print((max(a)-min(a)+1)//2)

Submission status: Accepted

Solution code:
lst=[]
N=int(input())
lst=[int(x) for x in input().split()]
a=max(lst)
b=min(lst)
print(a-((a+b)//2))

Submission status: Accepted

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

a=max(list)-min(list)
b=a//2
    
if a%2==0:
    print(b)
else:
    print(b+1)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
if max(a)-min(a)//2==0:
    b=(max(a)-min(a))//2
    print(b)
else:
    c=(max(a)-min(a)+1)//2
    print(c)

Submission status: Accepted

Solution code:
import math

N=int(input())

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

a=((min(i)+max(i))/2)
a=math.ceil(a)

print(a-min(i))

Submission status: Accepted

Solution code:
n=int(input())
x=list(map(int,input().split()))
if (max(x)-min(x))%2==0:
    print((max(x)-min(x))//2)
else:
    print((max(x)-min(x))//2+1)

Submission status: Accepted

Solution code:
N = int(input())
x = [int(i) for i in input().split()]
x.sort()
a = min(x)
b = max(x)
c = b-a
if c > 1:
    print(-(-c//2))
else:
    print(c)

Submission status: Accepted

Solution code:
n=int(input())
lis=list(map(int,input().split()))
a=max(lis)
b=min(lis)
x=a-b
y=-(-x//2)
print(y)

Submission status: Accepted

Solution code:
N=int(input())
x=list(map(int,input().split()))
print((max(x)-min(x)+1)//2)

Submission status: Accepted

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


if (max(i)-min(i))%2==0:
    print(int((max(i)-min(i))/2))
if (max(i)-min(i))%2==1:
    print(int((max(i)-min(i)+1)/2))

Submission status: Accepted

Solution code:
# (46)集会所
n=int(input())
l=list(map(int,input().split()))
a=max(l)
b=min(l)
c=(a+b+1)//2
print(abs(b-c))

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split()))
print((max(a)-min(a)+1)//2)

Submission status: Accepted

Solution code:
n=int(input())
x=list(map(int,input().split()))
if (max(x)+min(x))%2==0:
    m=(int((max(x)+min(x))/2))
else:
    m=(int((max(x)+min(x)-1)/2))
print(max(x)-m)

Submission status: Accepted

Solution code:
n=int(input())
x=list(map(int,input().split()))
s=max(x)-min(x)
if s%2==0:
    print(int(s/2))
else:
    print(int((s+1)/2))

Submission status: Accepted

Solution code:

n=int(input())
lst = list(map(int, input().strip().split()))
a=max(lst)
b=min(lst)
c=(a-b+1)/2

print(int(c))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
if (max(a)-min(a)) % 2 == 0:
    print((max(a)-min(a))//2)
else:
    print((max(a)-min(a))//2+1)

Submission status: Accepted

Solution code:
N = int(input())
lst1 = list(map(int,input().split()))
y = min(lst1)
z = max(lst1)
if (z-y)%2==0:
    print((z-y)//2)
else:
    print((z-y+1)//2)

Submission status: Accepted

Solution code:
N = int(input())
X = list(map(int, input().split()))
Xmn, Xmx = min(X), max(X)
temp = []
res = Xmx-Xmn
for x in range(Xmn, Xmx+1):
	for n in range(N):
		temp.append(abs(X[n]-x))
	if max(temp)<res:
		res = max(temp)
	temp=[]

print(res)

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split()))
min = min(a)
max = max(a)
b=max-min
if b%2!=0:
    b=b+1
b=b//2
print(b)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

n = int(input())
a = list(map(int, input().split()))
if (max(a)-min(a)) % 2 == 0:
    print((max(a)-min(a))//2)
else:
    print((max(a)-min(a))//2+1)

Submission status: Accepted

Solution code:
N=int(input())
lst=list(map(int,input().split()))
a=max(lst)-min(lst)
x=(a)//2
if a%2==0:
    print(x)
else:
    print(x+1)

Submission status: Accepted

Solution code:
N = int(input())
a = list(int(x) for x in input().split())
a.sort()
b = []
for i in range(a[0],a[N-1]+1):
  x = max(abs(i - a[0]),abs(i-a[N-1]))
  b.append(x)
print(min(b))

Submission status: Accepted

Solution code:
N=int(input())
x=[]
x=list(map(int,input().split()))
list.sort(x)
distance=(x[N-1]-x[0])//2
if N==1:print(0)
else:
    if distance==0:time=1
    elif (x[N-1]-x[0])%2==0:time=distance
    else:time=distance+1
    print(time)

Submission status: Accepted

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

Submission status: Accepted

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

print(max(x)-(min(x)+max(x))//2)

Submission status: Accepted

Solution code:
N=int(input())
s=list(map(int, input().split()))
t=max(s)-min(s)
print((t+1)//2)

Submission status: Accepted

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

lst.sort()

d = (lst[n-1]-lst[0])+1
print(d//2)

Submission status: Accepted

Solution code:
#47 集会所 Wrong Answer

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

x_max = max(x)
x_min = min(x)

print((x_max - x_min+1)//2)

Submission status: Accepted

Solution code:
N=input()
x_list=list(map(int,input().split()))
ans=(max(x_list)-min(x_list)+1)//2

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split()))
if (max(a)-min(a))%2==0:
    print((max(a)-min(a))//2)
else:
    print((max(a)-min(a))//2+1)

Submission status: Accepted

Solution code:
import math

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

#print(x)

if (max(x)-min(x))%2==0:
    print(
        math.ceil((max(x)-min(x))/2)
        )
    
elif (max(x)-min(x))%2!=0:
    print(
        math.ceil((max(x)-(min(x)-1))/2)
        )

Submission status: Accepted

Solution code:
N=int(input())
x=list(map(int, input().split()))
m=max(x)
n=min(x)
if (m-n)%2==0:
    print((m-n)//2)
else:
    print(((m-n)//2)+1)

Submission status: Accepted

Solution code:
N=int(input())

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


min=a[0]
i=0
for i in range(N):
    if a[i]<min:
        k=0
        k=a[i]
        a[i]=min
        min=k
    i+=1

max=a[0]
i=0
for i in range(N):
    if a[i]>max:
        k=0
        k=a[i]
        a[i]=max
        max=k
    i+=1
    
c=max-min
import math

print(int(math.ceil(c/2)))

Submission status: Accepted

Solution code:
import math
N=int(input())
line=input()
a=[]
t = line.split(" ")
for i in range(0,N):
    a.append(int(t[i]))

A = []
for n in a:
    A.append(n-min(a))
print(math.ceil((max(A)+min(A))/2))

Submission status: Accepted

Solution code:
N = int(input())
data = list(map(int,input().split()))
a = max(data)
b = min(data)
print((a-b+1)//2)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
x=max(a)
y=min(a)
w=x-y
if w%2==0:
    print(w//2)
else:
    print(w//2+1)

Submission status: Accepted

Solution code:
n = int(input())
data = list(map(int, input().split()))
#print(max(data),min(data))
l = max(data) - min(data)
meet = -(-l //2)
print(meet)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
    
x=max(l)-min(l)
    
if x==1:
    print("1")
elif x%2==0:
    print(x//2)
else:
    print(x//2+1)

Submission status: Accepted

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


if (max(x)-min(x))%2==0:
    
    y=int((max(x)-min(x))/2)
else:
    y=int((max(x)-min(x)+1)/2)
    
print(y)

Submission status: Accepted

Solution code:
N = int(input())
if N >= 2:
    n = list(map(int,input().split()))
    a = sorted(n)
    if (a[N-1]-a[0])%2 ==0:
        y =int((a[N-1]-a[0])//2)
        print(y)
    else:
        y = int((a[N-1]-a[0]+1)//2)
        print(y)
elif N == 1 :
    print(0)

Submission status: Accepted

Solution code:
n = int(input())

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


print(max(x)-((min(x)+max(x))//2))

Submission status: Accepted

Solution code:
x=int(input())
a=input().split()
j=0
while j<x :
    a[j]=int(a[j])
    j=j+1
i=0
while i<x :
    k=0
    while k<(x-1) :
        if a[k]>a[k+1] : 
            tmp=a[k]
            a[k]=a[k+1]
            a[k+1]=tmp
        k=k+1
    i=i+1
mx=int(a[x-1])
mn=int(a[0])
if (mx-mn)%2>0 : ans=(mx-mn)//2+1
else : ans=(mx-mn)/2
print(int(ans))

Submission status: Accepted

Solution code:
N=int(input())
n=list(map(int,input().split()))
if N >= 2:
    a=sorted(n)
    if (a[N-1]-a[0])%2 == 0:
        print((a[N-1]-a[0])//2)
    else:
        print((a[N-1]-a[0]+1)//2)
elif N == 1:
    print(0)

Submission status: Accepted

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

s = max(x) - min(x)
if s == 1:
   print("1")
else:
   if s % 2 == 0:
      print(int(s / 2))
   else:
      print(int(s / 2) + 1)

Submission status: Accepted

Solution code:
#0407
N = int(input())
x = list(map(int,input().split()))
x.sort()
a = int(x[0])
b = int(x[N-1])
if a%2 == 0 and b%2 == 0:
    print((b - a)//2)
else:
    print((b - a + 1)//2)

Submission status: Accepted

Solution code:
# coding: utf-8
# 47

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

I.sort()

if (I[n-1]-I[0])%2==0:
    print((I[n-1]-I[0])//2)
else:
    print((I[n-1]-I[0])//2+1)

Submission status: Accepted

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

t=max(x)-min(x)
if t%2==0:
    y=int(t/2)
else:
    y=int((t+1)/2)
print(y)

Submission status: Accepted

Solution code:

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

a = max(x)-min(x)

if a%2==0:
    print(a//2)
else:
    a += 1
    print(a//2)

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int, input().split()))
a = max(x) + min(x)
b = a//2
print(max(x) - b)

Submission status: Accepted

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

mintime = 1000000000000

for i in range(2000+1):
    tmpmin = 0
    for j in x:
        tmpmin = max(tmpmin, abs(i-j))
    if tmpmin < mintime:
        mintime = tmpmin
print(mintime)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

s = max(l) - min(l)
if s == 1:
   print("1")
else:
   if s % 2 == 0:
      print(int(s / 2))
   else:
      print(int(s / 2) + 1)

Submission status: Accepted

Solution code:
n=int(input())

a=input().split()

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

mina=min(a)
maxa=max(a)



print((maxa-mina+1)//2)

Submission status: Accepted

Solution code:
N = int(input())
x_array = sorted([int(x) for x in input().split()])
dif = int((x_array[-1] + x_array[0])/2)
print(x_array[-1]-dif)

Submission status: Accepted

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

for i in range(N):
    for j in range(N-1,0,-1):
        if xlist[j-1]>xlist[j]:
            xlist[j-1],xlist[j] = xlist[j],xlist[j-1]

if (xlist[N-1]-xlist[0])%2 == 0:
    T = (xlist[N-1]-xlist[0])//2

if (xlist[N-1]-xlist[0])%2 > 0 : 
    T = (xlist[N-1]-xlist[0])/2+0.5

print(int(T))

Submission status: Accepted

Solution code:
N=int(input())
x=list(map(int,input().split()))
min_x=min(x)
max_x=max(x)
m1=(min_x+max_x)//2
m2=(min_x+max_x+1)//2
print(min([max(max_x-m1,m1-min_x),max(max_x-m2,m2-min_x)]))

Submission status: Accepted

Solution code:
a=int(input())
b=list(map(int,input().split()))
if (max(b)-min(b))%2==0:
    print((max(b)-min(b))//2)
else:
    print((max(b)-min(b))//2+1)

Submission status: Accepted

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

distance = max(arr) - min(arr)

if distance % 2 == 0:
    print(distance // 2)
else:
    print(distance // 2 + 1)

Submission status: Accepted

Solution code:
N=int(input())
table=list(map(int,input().split()))
if (max(table)-min(table))%2==0:
    print((max(table)-min(table))//2)
else:
    print(((max(table)-min(table))//2)+1)

Submission status: Accepted

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

sub = max(X) - min(X)

if sub % 2 == 0 :
    print(sub // 2)
else :
    print(sub // 2 + 1)

Submission status: Accepted

Solution code:

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

minX = 9999
maxX = -1

for i in range(N):
    minX = min(minX, x[i])
    maxX = max(maxX, x[i])
    
print((maxX-minX+1)//2)

Submission status: Accepted

Solution code:

if __name__ == '__main__':

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

	l = min(B)
	r = max(B)

	ans = r - (l + r ) // 2 
	print(ans)

Submission status: Accepted

Solution code:
n = int(input())
houses = list(map(int,input().split()))
houses.sort()
building = (houses[-1] - houses[0]) / 2 
if type(building) == float:
    building += 0.5
print(int(building))

Submission status: Accepted

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

min_x, max_x = xlist[0], xlist[-1]
ans = 10**9
for x in range(2000+1):
    ans = min(ans, max(x - min_x, max_x - x))
print(ans)

Submission status: Accepted

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

ans = 1000000000000
for p in range(min, max + 1):
  now = 0
  for q in x:
    if now < abs(p - q):
      now = abs(p - q)
  if ans > now:
    ans = now
print(ans)

Submission status: Accepted

Solution code:
input()
x = input() # x = "4 0 2"
list_a = x.split() # list_moji = ["4", "0", "2"]
list_num = []
for i in list_a:
    list_num.append(int(i))
answer = max(list_num) - (min(list_num) + max(list_num))//2
print(answer)

Submission status: Accepted

Solution code:
input()
l = [int(i) for i in input().split()]
print(max(l) - (min(l) + max(l))//2)

Submission status: Accepted

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

memory = max([abs(int(p)-a[0]) for p in a])
for i in range(a[0]+1,a[n-1]+1):
    memory1 = max([abs(int(t)-i) for t in a])
    memory = min(memory,memory1)
print(memory)

Submission status: Accepted

Solution code:
import math
N = int(input())
x = [int(x) for x in input().split()]
print(math.ceil((max(x) - min(x)) / 2))

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int,input().split()))
#print((max(x) + min(x))/2)
print(max(x) - int((max(x) + min(x))/2))

Submission status: Accepted

Solution code:
a = int(input())
b = list(map(int,input().split()))
b = sorted(b)
way = b[-1]-b[0]
if way%2 == 1:
    print((way+1)//2)
else:
    print(way//2)

Submission status: Accepted

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

m = max(houses)
n = min(houses)

print((m-n+1)//2)

Submission status: Accepted

Solution code:
n, *a = map(int, open(0).read().split())
print((max(a) - min(a) + 1)//2)

Submission status: Accepted

Solution code:
import math
n = int(input())
lis = list(map(int,input().split()))
print(math.ceil((max(lis)-min(lis))/2))

Submission status: Accepted

Solution code:
n=int(input())
x=list(map(int,input().split()))
mi=min(x)
ma=max(x)
m1=(mi+ma)//2
m2=(mi+ma)//2+1
print(min([max(ma-m1,m1-mi),max(ma-m2,m2-mi)]))

Submission status: Accepted

Solution code:
import math

times = int(input())
lst = list(map(int, input().split(" ")))

print(math.ceil((max(lst) - min(lst)) / 2))