A sequence $a_1, a_2, \dots, a_k$ is called an arithmetic progression if for each $i$ from $1$ to $k$ elements satisfy the condition $a_i = a_1 + c \cdot (i - 1)$ for some fixed $c$.

For example, these five sequences are arithmetic progressions: $[5, 7, 9, 11]$, $[101]$, $[101, 100, 99]$, $[13, 97]$ and $[5, 5, 5, 5, 5]$. And these four sequences aren't arithmetic progressions: $[3, 1, 2]$, $[1, 2, 4, 8]$, $[1, -1, 1, -1]$ and $[1, 2, 3, 3, 3]$.

You are given a sequence of integers $b_1, b_2, \dots, b_n$. Find any index $j$ ($1 \le j \le n$), such that if you delete $b_j$ from the sequence, you can reorder the remaining $n-1$ elements, so that you will get an arithmetic progression. If there is no such index, output the number -1.


-----Input-----

The first line of the input contains one integer $n$ ($2 \le n \le 2\cdot10^5$) — length of the sequence $b$. The second line contains $n$ integers $b_1, b_2, \dots, b_n$ ($-10^9 \le b_i \le 10^9$) — elements of the sequence $b$.


-----Output-----

Print such index $j$ ($1 \le j \le n$), so that if you delete the $j$-th element from the sequence, you can reorder the remaining elements, so that you will get an arithmetic progression. If there are multiple solutions, you are allowed to print any of them. If there is no such index, print -1.


-----Examples-----
Input
5
2 6 8 7 4

Output
4
Input
8
1 2 3 4 5 6 7 8

Output
1
Input
4
1 2 4 8

Output
-1


-----Note-----

Note to the first example. If you delete the $4$-th element, you can get the arithmetic progression $[2, 4, 6, 8]$.

Note to the second example. The original sequence is already arithmetic progression, so you can delete $1$-st or last element and you will get an arithmetical progression again.

Difficulty: MEDIUM_HARD

Solutions:
def fu(a, b):
	e = 0
	for i in range(1, len(a)):
		if a[i] != a[0] + i * b:
			e += 1
			if e == 1:
				f = i
			if e > 1:
				e = -1
			break
	if e == -1:
		return -1
	else:
		return f
n = int(input())
a = list(map(int, input().split()))
a = [[a[i], i] for i in range(n)]
a.sort()
if n < 4:
	print(a[0][1] + 1)
else:
	b = []
	for i in range(n):
		b.append(a[i][0])
	e = 0
	for i in range(1, n):
		if b[i] != b[1] + (i - 1) * (b[2] - b[1]):
			e = -1
			break
	if e == -1:
		d = [b[0]] + b[2:]
		e = 0
		for i in range(len(d)):
			if d[i] != d[0] + i * (d[1] - d[0]):
				e = -1
				break
		if e == -1:
			e = 0
			i = 0
			while i < n:
				if b[i] != b[0] + (i - e) * (b[1] - b[0]):
					e += 1
					if e == 1:
						f = a[i][1] + 1
					if e > 1:
						e = -1
						break
				i += 1
			if e == -1:
				print(e)
			else:
				print(f)
		else:
			print(a[1][1] + 1)
	else:
		print(a[0][1] + 1)


n = int(input())
b = list(map(int, input().split()))
b_ = []
for (i, t) in enumerate(b):
	b_.append([t, i + 1])
b_.sort()

def solve(s):

	def check(a):
		if len(a) <= 1:
			return True
		delta = a[1] - a[0]
		for i in range(1, len(a) - 1):
			if a[i + 1] - a[i] != delta:
				return False
		return True
	if check([x[0] for x in s[1:]]):
		return s[0][1]
	if check([x[0] for x in s[:-1]]):
		return s[-1][1]
	if check([x[0] for x in s[:1] + s[2:]]):
		return s[1][1]
	if check([x[0] for x in s[:-2] + s[-1:]]):
		return s[-2][1]
	t = []
	for i in range(len(s) - 1):
		t.append(s[i + 1][0] - s[i][0])
	i = 0
	while t[i] == t[0]:
		i += 1
	j = len(t) - 1
	while t[j] == t[-1]:
		j -= 1
	if t[0] == t[-1]:
		if i != j - 1:
			return -1
		if t[i] + t[j] != t[0]:
			return -1
		return s[j][1]
	else:
		if i != j:
			return -1
		if i == 1 and t[0] + t[1] == t[2]:
			return s[1][1]
		if j == len(t) - 2 and t[j] + t[j + 1] == t[j - 1]:
			return s[len(t) - 1][1]
		return -1
print(solve(b_))


import sys
from collections import Counter
from operator import itemgetter
n = int(sys.stdin.readline().strip())
if n < 3:
	print('1')
	return
times = list(enumerate(map(int, sys.stdin.readline().split())))
times.sort(key=itemgetter(1))
origindices = [t[0] for t in times]
times = [t[1] for t in times]
c = times[2] - times[1]
a = times[1]
success = True
for i in range(2, n):
	if times[i] != a + c * (i - 1):
		success = False
		break
if success:
	print(origindices[0] + 1)
	return
a = times[0]
c = times[2] - times[0]
success = True
for i in range(2, n):
	if times[i] != a + c * (i - 1):
		success = False
		break
if success:
	print(origindices[1] + 1)
	return
removednum = 1
success = True
a = times[0]
c = times[1] - times[0]
for i in range(2, n):
	if removednum == 1 and times[i] != a + c * i or (removednum != 1 and times[i] != a + c * (i - 1)):
		if removednum == 1:
			removednum = i
		else:
			success = False
			break
if success:
	print(origindices[removednum] + 1)
	return
print(-1)


import sys
from collections import defaultdict
input = lambda : sys.stdin.readline().strip()
write = lambda x: sys.stdout.write(x)
n = int(input())
arr = sorted([(j, i + 1) for (i, j) in enumerate(map(int, input().split()))])
if n <= 3:
	print(arr[0][1])
	return
(a1, a2, a3) = (arr[0][0], arr[1][0], arr[2][0])
(c1, c2, c3) = (a3 - a2, a3 - a1, a2 - a1)
flag = True
x = a2
for i in range(n):
	if i == 0:
		continue
	if arr[i][0] != x:
		flag = False
		break
	else:
		x += c1
if flag:
	print(arr[0][1])
	return
flag = True
x = a1
for i in range(n):
	if i == 1:
		continue
	if arr[i][0] != x:
		flag = False
		break
	else:
		x += c2
if flag:
	print(arr[1][1])
	return
flag = []
x = a1
for i in range(n):
	if arr[i][0] != x:
		flag.append(arr[i])
	else:
		x += c3
if len(flag) >= 2:
	print(-1)
else:
	print(flag[0][1])


n = int(input())
a = []
i = 0
for el in map(int, input().split()):
	a.append((el, i))
	i += 1
a.sort()
if n == 2:
	print(1)
	return
st = a[2][0] - a[1][0]
for i in range(1, n - 1):
	if a[i + 1][0] - a[i][0] != st:
		break
else:
	print(a[0][1] + 1)
	return
st = a[2][0] - a[0][0]
for i in range(2, n - 1):
	if a[i + 1][0] - a[i][0] != st:
		break
else:
	print(a[1][1] + 1)
	return
st = a[1][0] - a[0][0]
i = 1
found = -1
while i < n - 1:
	if a[i + 1][0] - a[i][0] != st:
		if found != -1:
			print(-1)
			return
		else:
			found = i + 1
			i += 1
	i += 1
t = a.pop(found)
for i in range(n - 2):
	if a[i + 1][0] - a[i][0] != st:
		print(-1)
		break
else:
	print(t[1] + 1)
	return


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 998244353
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def AP(b):
	d = b[1][0] - b[0][0]
	for i in range(1, len(b)):
		if b[i][0] - b[i - 1][0] != d:
			return False
	return True
n = Int()
a = array()
a = [(a[i], i + 1) for i in range(n)]
a.sort()
d = defaultdict(int)
for i in range(1, n):
	d[a[i][0] - a[i - 1][0]] += 1
if AP(a):
	print(a[0][1])
elif AP(a[1:]):
	print(a[0][1])
elif AP(a[:-1]):
	print(a[-1][1])
else:
	for i in range(1, n - 1):
		d1 = a[i][0] - a[i - 1][0]
		d2 = a[i + 1][0] - a[i][0]
		d[d1] -= 1
		d[d2] -= 1
		if not d[d1]:
			del d[d1]
		if not d[d2]:
			del d[d2]
		d3 = a[i + 1][0] - a[i - 1][0]
		d[d3] += 1
		if len(d) == 1:
			print(a[i][1])
			exit()
		d[d3] -= 1
		if not d[d3]:
			del d[d3]
		d[d1] += 1
		d[d2] += 1
	print(-1)


def check(x):
	arr2 = []
	for i in range(n):
		if i != x:
			arr2.append(arr_index[i])
	if len(arr2) > 2:
		d1 = arr2[1][0] - arr2[0][0]
		for k in range(len(arr2) - 1):
			if arr2[k + 1][0] - arr2[k][0] != d1:
				return 0
	print(arr_index[x][1] + 1)
	exit()
n = int(input())
arr = list(map(int, input().split()))
arr_index = []
for i in range(n):
	arr_index.append((arr[i], i))
arr_index = sorted(arr_index, key=lambda l: l[0])
check(0)
check(n - 1)
d = 0
for i in range(n - 1):
	d = max(d, arr_index[i + 1][0] - arr_index[i][0])
count = 0
for i in range(n - 1):
	if arr_index[i + 1][0] - arr_index[i][0] != d:
		check(i)
		check(i + 1)
		count += 1
		if count > 2:
			break
print('-1')


import sys, math

def read_int():
	return int(sys.stdin.readline().strip())

def read_int_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def read_string():
	return sys.stdin.readline().strip()

def read_string_list(delim=' '):
	return sys.stdin.readline().strip().split(delim)

def print_list(l):
	print(' '.join(map(str, l)))

def check_ap(arr):
	diffs = set()
	for i in range(len(arr) - 1):
		diffs.add(arr[i + 1][1] - arr[i][1])
	return len(diffs) == 1
n = read_int()
arr = read_int_list()
if n <= 2:
	print(1)
	sys.exit()
for i in range(n):
	arr[i] = (i + 1, arr[i])
arr.sort(key=lambda x: x[1])
diffs = set()
for i in range(n - 1):
	diffs.add(arr[i + 1][1] - arr[i][1])
if len(diffs) > 3:
	print(-1)
	sys.exit()
if check_ap(arr[1:]):
	print(arr[0][0])
	sys.exit()
if check_ap([arr[0]] + arr[2:]):
	print(arr[1][0])
	sys.exit()
a = arr[1][1] - arr[0][1]
for i in range(n - 1):
	if arr[i + 1][1] - arr[i][1] != a:
		if check_ap(arr[:i + 1] + arr[i + 2:]):
			print(arr[i + 1][0])
			sys.exit()
		else:
			print(-1)
			sys.exit()


n = int(input())
b = input().split()
for i in range(n):
	b[i] = [int(b[i]), i]
b.sort()
if n == 2:
	print(1)
else:
	flag1 = True
	for i in range(2, n):
		if b[i][0] - b[i - 1][0] != b[2][0] - b[1][0]:
			flag1 = False
	flag2 = True
	for i in range(3, n):
		if b[i][0] - b[i - 1][0] != b[2][0] - b[0][0]:
			flag2 = False
	if flag1:
		print(b[0][1] + 1)
	elif flag2:
		print(b[1][1] + 1)
	else:
		d = b[1][0] - b[0][0]
		for i in range(2, n):
			if b[i][0] - b[i - 1][0] != d:
				break
		element = b[i]
		b.pop(i)
		flag = True
		for i in range(2, n - 1):
			if b[i][0] - b[i - 1][0] != d:
				flag = False
		if flag:
			print(element[1] + 1)
		else:
			print(-1)


n = int(input())
a = [int(x) for x in input().split()]
for i in range(n):
	a[i] = (a[i], i + 1)
a.sort()
b = []
for i in range(1, n):
	b.append(a[i][0] - a[i - 1][0])
if len(b) == 1:
	print(1)
elif sorted(b[1:])[0] == sorted(b[1:])[-1]:
	print(a[0][1])
elif sorted(b[:-1])[0] == sorted(b[:-1])[-1]:
	print(a[-1][1])
else:
	for i in range(n - 2):
		if b[i] + b[i + 1] == b[0] or b[i] + b[i + 1] == b[-1]:
			c = sorted(b[:i] + [b[i] + b[i + 1]] + b[i + 2:])
			if c[0] == c[-1]:
				print(a[i + 1][1])
				break
			else:
				print(-1)
				break
	else:
		print(-1)


import sys
input = sys.stdin.readline

def check(dic):
	count = 0
	for i in dic:
		if dic[i] != 0:
			count += 1
	if count != 1:
		return False
	else:
		return True
n = int(input())
ar = list(map(int, input().split()))
li = []
for i in range(n):
	li.append([i, ar[i]])
li.sort(key=lambda x: x[1])
dif = []
for i in range(1, n):
	dif.append(li[i][1] - li[i - 1][1])
dic = {}
for i in range(n - 1):
	if dif[i] in dic:
		dic[dif[i]] += 1
	else:
		dic[dif[i]] = 1
le = len(dic)
if le == 1:
	print(li[0][0] + 1)
elif le > 3:
	print(-1)
else:
	tem = dic.copy()
	tem[dif[0]] -= 1
	if check(tem):
		print(li[0][0] + 1)
	else:
		tem = dic.copy()
		tem[dif[-1]] -= 1
		if check(tem):
			print(li[-1][0] + 1)
		else:
			flag = True
			for i in range(n - 2):
				tem = dic.copy()
				tem[dif[i]] -= 1
				tem[dif[i + 1]] -= 1
				ne = dif[i] + dif[i + 1]
				if ne in tem:
					tem[ne] += 1
				else:
					tem[ne] = 1
				if check(tem):
					print(li[i + 1][0] + 1)
					flag = False
					break
			if flag:
				print(-1)