-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeForces-1154B.py
More file actions
72 lines (56 loc) · 1.56 KB
/
CodeForces-1154B.py
File metadata and controls
72 lines (56 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from collections import *
from math import *
from heapq import *
from itertools import *
from queue import *
from cmath import *
from random import *
from functools import *
from time import *
from typing import *
import sys
import os
import decimal
def INPUTS():
#n = int(sys.stdin.readline().strip())
#arrary = [int(sys.stdin.readline().strip()) for _ in range(n)]
SINGLE_INT = lambda:int(input())
#MINGLE_INT = lambda:map(int,input().split())
#SINGLE_STR = lambda:input().strip()
# MINGLE_STR = lambda:map(str,input().split())
LIST_INT = lambda:list(map(int,input().split()))
#LIST_INT2 = lambda:list(map(int,input().split()))
# LIST_STR = lambda:list(map(str,input().split()))
# LIST_SORTED = lambda:sorted(list(map(int,input().split())))
n = SINGLE_INT()
l = LIST_INT()
return n,l
def solution():
n,l=INPUTS()
l = sorted(l)
s = set()
if len(set(l))>3:
print(-1)
return
if len(set(l)) == 1:
print(0)
return
if len(set(l)) == 2:
if ((max(l)-min(l))/2).is_integer():
print((max(l)-min(l))//2)
else:
print(max(l)-min(l))
if len(set(l)) == 3:
s = sorted(set(l))
if s[2]-s[1] == s[1]-s[0]:
print(s[1]-s[0])
else:
print(-1)
def main():
# test_cases = int(input())
# for T in range(test_cases):
# solution()
#print(f'Case{T+1}:{solution()}')
solution()
if __name__ == '__main__':
main()