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
Tags: Mathematics

Implementation

Starter code:

Solutions:
import sys
IS_LOCAL = False

def readMultiple(f):
	return f(map(int, input().split()))

def check_seq(n, a):
	d = a[1][0] - a[0][0]
	(found, ind, prev) = (False, a[0][1], a[1][0])
	for i in range(2, n):
		if abs(a[i][0] - prev - d) > 0.1:
			if found:
				return (False, -1)
			found = True
			ind = a[i][1]
			continue
		prev = a[i][0]
	return (True, ind)

def main():
	n = 5
	a = [2, 6, 8, 7, 4]
	if not IS_LOCAL:
		n = int(input())
		a = readMultiple(list)
	if n <= 3:
		print(1)
		return
	a = [(x, i + 1) for (i, x) in enumerate(a)]
	a = sorted(a)
	(is_good, ind) = check_seq(n, a)
	if not is_good:
		(is_good, ind) = check_seq(n, list(reversed(a)))
	print(ind)
if len(sys.argv) > 1 and sys.argv[1] == 'True':
	IS_LOCAL = True
main()


def find_spy(n, b):
	sorted_b = sorted(b)
	diffs = [sorted_b[i] - sorted_b[i - 1] for i in range(1, n)]
	if (sorted_b[-1] - sorted_b[1]) % (n - 2) == 0:
		c = (sorted_b[-1] - sorted_b[1]) // (n - 2)
		is_feasible = True
		for i in range(1, n - 1):
			if diffs[i] != c:
				is_feasible = False
				break
		if is_feasible:
			return sorted_b[0]
	if (sorted_b[-2] - sorted_b[0]) % (n - 2) == 0:
		c = (sorted_b[-2] - sorted_b[0]) // (n - 2)
		is_feasible = True
		for i in range(n - 2):
			if diffs[i] != c:
				is_feasible = False
				break
		if is_feasible:
			return sorted_b[-1]
	if (sorted_b[-1] - sorted_b[0]) % (n - 2) == 0:
		c = (sorted_b[-1] - sorted_b[0]) // (n - 2)
		for i in range(n - 2):
			if diffs[i] + diffs[i + 1] == c:
				return sorted_b[i + 1]
	return None

def solve(n, b):
	if n == 2:
		return 1
	spy = find_spy(n, b)
	return -1 if spy is None else b.index(spy) + 1
n = int(input())
b = list(map(int, input().split()))
print(solve(n, b))


import sys
import math
from itertools import permutations
input = sys.stdin.readline
n = int(input())
arr = list(map(int, input().split()))
index = []
for i in range(n):
	index.append(i + 1)
res = sorted(zip(arr, index))
num = []
count = []
for i in range(1, n):
	flag1 = True
	for j in range(len(num)):
		if res[i][0] - res[i - 1][0] == num[j][0]:
			num[j][1] += 1
			flag1 = False
	if flag1:
		num.append([res[i][0] - res[i - 1][0], 1])
	if len(num) > 3:
		print(-1)
		break
if len(num) == 1:
	print(res[0][1])
elif len(num) <= 3:
	star = []
	for j in range(1, n):
		for k in range(len(num)):
			if num[k][0] == res[j][0] - res[j - 1][0] and num[k][1] <= 2:
				star.append(j)
	f = True
	for j in star:
		ans = []
		flag = True
		for k in range(1, n):
			if k != j and k != j + 1 and (res[k][0] - res[k - 1][0] not in ans):
				ans.append(res[k][0] - res[k - 1][0])
			elif k != j and k == j + 1 and (res[k][0] - res[k - 2][0] not in ans):
				ans.append(res[k][0] - res[k - 2][0])
			elif k == j and j != n - 1 and (res[k + 1][0] - res[k - 1][0] not in ans):
				ans.append(res[k + 1][0] - res[k - 1][0])
			if len(ans) > 1:
				flag = False
				break
		if flag:
			print(res[j][1])
			f = False
			break
	if f:
		f1 = True
		diff = res[2][0] - res[1][0]
		for j in range(2, n):
			if res[j][0] - res[j - 1][0] != diff:
				f1 = False
				break
		if f1:
			print(res[0][1])
		else:
			print(-1)


from collections import Counter
n = int(input())
l = list(map(int, input().rstrip().split()))
f = 0
if len(l) <= 3:
	print(1)
	exit()
z = {i + 1: l[i] for i in range(n)}
so = sorted(z.items(), key=lambda x: (x[1], x[0]))
d = [so[i + 1][1] - so[i][1] for i in range(n - 1)]
c = set(d)
if len(c) == 1:
	print(so[0][0])
	exit()
if len(c) > 3:
	print(-1)
	exit()
j = -1
if len(set(d[1:])) == 1 and so[2][1] - so[1][1] != so[1][1] - so[0][1]:
	j = so[0][0]
	f = 1
if f == 0:
	if len(set(d[2:])) == 1 and so[2][1] - so[0][1] == so[3][1] - so[2][1]:
		j = so[1][0]
		f = 1
D = so[1][1] - so[0][1]
if f == 0:
	for i in range(1, n - 2):
		if so[i + 1][1] - so[i][1] != D and so[i + 2][1] - so[i][1] == D:
			j = so[i + 1][0]
			f = 1
			break
		if so[i + 1][1] - so[i][1] != D and so[i + 2][1] - so[i][1] != D:
			print(-1)
			exit()
if f == 0:
	if so[n - 1][1] - so[n - 2][1] != D:
		j = so[n - 1][0]
		f = 1
if f:
	print(j)
	exit()
print(-1)


import sys
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
for i in range(n):
	arr[i] = [arr[i], i]
arr.sort()
if n <= 3:
	print(1)
else:
	c = arr[2][0] - arr[1][0]
	z = True
	for i in range(1, n - 1):
		if arr[i + 1][0] - arr[i][0] != c:
			z = False
			break
	if z:
		print(arr[0][1] + 1)
	else:
		d = arr[2][0] - arr[0][0]
		z = True
		for i in range(2, n - 1):
			if arr[i + 1][0] - arr[i][0] != d:
				z = False
				break
		if z:
			print(arr[1][1] + 1)
		else:
			ind = -1
			count = 0
			d = arr[1][0] - arr[0][0]
			l = [arr[0][0], arr[1][0]]
			for i in range(2, n):
				l.append(l[-1] + d)
			rem = -10000000000
			count = 0
			j = 0
			for i in range(n):
				if arr[i][0] != l[j]:
					count += 1
					rem = arr[i][1] + 1
				else:
					j += 1
			if count > 1:
				print(-1)
			else:
				print(rem)


import math
n = int(input())
l = [int(i) for i in input().split()]
ab = l[:]
l.sort()
if len(l) == 2 or len(l) == 3:
	print(1)
elif (n - 1) * (2 * l[0] + (n - 2) * (l[1] - l[0])) / 2 == sum(l[:n - 1]):
	print(ab.index(l[-1]) + 1)
elif (n - 1) * (2 * l[0] + (n - 2) * (l[1] - l[0])) / 2 == sum(ab[:n - 1]):
	print(n)
elif (n - 1) * (2 * l[1] + (n - 2) * (l[-1] - l[-2])) / 2 == sum(l[1:]):
	print(ab.index(l[0]) + 1)
else:
	summa = []
	change = []
	difference = []
	for i in range(len(l) - 1):
		difference.append(l[i + 1] - l[i])
	if len(set(difference)) in range(2, 4):
		max_ = max(set(difference))
		freq = difference.count(max_)
		if freq >= len(difference) - 2:
			if sum(set(difference)) == 2 * max_ or sum(set(difference)) == 1.5 * max_ or sum(set(difference)) == max_:
				for i in range(0, len(difference)):
					if difference[i] != max_:
						change.append(i)
		try:
			print(ab.index(l[change[-1]]) + 1)
		except:
			print(-1)
	elif len(set(difference)) == 1:
		print(1)
	else:
		print(-1)


from sys import stdin
n = int(stdin.readline().strip())
s = list(map(int, stdin.readline().strip().split()))
if n <= 3:
	print(1)
	exit(0)
s1 = []
for i in range(n):
	s1.append([s[i], i])
s1.sort()
st = set()
for i in range(1, n):
	st.add(s1[i][0] - s1[i - 1][0])
if len(st) > 3:
	print(-1)
	exit(0)
yy = s1[2][0] - s1[1][0]
tt = True
for i in range(2, n):
	if s1[i][0] - s1[i - 1][0] != yy:
		tt = False
		break
if tt:
	print(s1[0][1] + 1)
	exit(0)
st = list(st)
d = st[0]
y = 0
ans = -1
xxx = -1
for i in range(1, n):
	if s1[i][0] - s1[i - 1][0] != d:
		if xxx == i:
			continue
		if y == 0:
			xxx = i + 1
			ans = s1[i][1] + 1
			y += 1
		else:
			ans = -1
			break
		if i + 1 < n and s1[i + 1][0] - s1[i - 1][0] != d:
			ans = -1
			break
if ans != -1:
	print(ans)
	exit(0)
if len(st) == 2:
	d = st[1]
	y = 0
	ans = -1
	xxx = -1
	for i in range(1, n):
		if s1[i][0] - s1[i - 1][0] != d:
			if xxx == i:
				continue
			if y == 0:
				xxx = i + 1
				ans = s1[i][1] + 1
				y += 1
			else:
				ans = -1
				break
			if i + 1 < n and s1[i + 1][0] - s1[i - 1][0] != d:
				ans = -1
				break
	if ans != -1:
		print(ans)
		exit(0)
if len(st) == 3:
	d = st[2]
	y = 0
	ans = -1
	xxx = -1
	for i in range(1, n):
		if s1[i][0] - s1[i - 1][0] != d:
			if xxx == i:
				continue
			if y == 0:
				xxx = i + 1
				ans = s1[i][1] + 1
				y += 1
			else:
				ans = -1
				break
			if i + 1 < n and s1[i + 1][0] - s1[i - 1][0] != d:
				ans = -1
				break
	if ans != -1:
		print(ans)
		exit(0)
print(-1)


B = []
a = int(input())
A = list(map(int, input().split()))
for i in range(a):
	A[i] = (A[i], i)
A.sort()
z = 0
k = abs(A[0][0] - A[1][0])
for i in range(a):
	if A[i][0] != A[0][0] + k * (i + z):
		B.append(i)
		z -= 1
if len(B) == 0:
	print(A[-1][1] + 1)
elif len(B) == 1:
	print(A[B[0]][1] + 1)
else:
	z = 0
	B = []
	k = abs(A[0][0] - A[2][0])
	for i in range(a):
		if A[i][0] != A[0][0] + k * (i + z):
			B.append(i)
			z -= 1
	if len(B) == 1:
		print(A[B[0]][1] + 1)
	else:
		z = 0
		B = []
		k = abs(A[1][0] - A[2][0])
		for i in range(a):
			if A[i][0] != A[1][0] + k * (i + z):
				B.append(i)
				z -= 1
		if len(B) == 1:
			print(A[B[0]][1] + 1)
		else:
			print(-1)


from copy import copy
from collections import Counter
x = input()
n = int(x)
x = input()
b = list(map(int, x.split()))
a = copy(b)
a.sort()
diff = [a[i + 1] - a[i] for i in range(len(a) - 1)]
c = Counter(diff)
num = len(c.keys())
if num == 1:
	print(b.index(a[0]) + 1)
elif num > 3:
	print(-1)
elif num == 2:
	if c[a[1] - a[0]] == 1:
		print(b.index(a[0]) + 1)
	elif c[a[-1] - a[-2]] == 1:
		print(b.index(a[-1]) + 1)
	else:
		(k1, k2) = sorted(list(c.keys()))
		if k1 == 0 and c[k1] == 1:
			print(b.index(a[diff.index(0)]) + 1)
		elif k1 * 2 == k2:
			if diff[diff.index(k1) + 1] == k1:
				print(b.index(a[diff.index(k1) + 1]) + 1)
			else:
				print(-1)
		else:
			print(-1)
else:
	k = sorted(list(c.keys()))
	va = sorted(list(c.values()))
	if va[1] > 1:
		print(-1)
	elif k[0] + k[1] == k[2]:
		print(b.index(max(a[diff.index(k[0])], a[diff.index(k[1])])) + 1)
	else:
		print(-1)


def mp():
	return map(int, input().split())
n = int(input())
t = list(mp())
a = sorted(t)
b = [0] * (n - 1)
for i in range(n - 1):
	b[i] = a[i + 1] - a[i]
if b.count(b[0]) == len(b) or n <= 3:
	for i in range(n):
		if t[i] == a[0]:
			print(i + 1)
			break
else:
	for i in [0, n - 1]:
		aa = a[:i] + a[i + 1:]
		d = [0] * (n - 2)
		for j in range(n - 2):
			d[j] = aa[j + 1] - aa[j]
		if d.count(d[0]) == n - 2:
			for j in range(n):
				if t[j] == a[i]:
					print(j + 1)
					break
			break
	else:
		d = dict()
		for i in b:
			d[i] = 0
		for i in b:
			d[i] += 1
		e = -1
		for i in range(1, n - 1):
			tmp = a[i + 1] - a[i - 1]
			if tmp in d and d[tmp] + 1 - int(a[i + 1] - a[i] == tmp) - int(a[i] - a[i - 1] == tmp) == n - 2:
				e = i
		if e == -1:
			print(-1)
		else:
			for i in range(n):
				if t[i] == a[e]:
					print(i + 1)
					break
			else:
				print(9 ** 9 ** 9)


n = int(input())
h = [[int(i), 0] for i in input().split()]
for j in range(n):
	h[j][1] = j + 1
h.sort(key=lambda x: x[0])
if n == 2:
	print(1)
	exit()
c = (h[n - 1][0] - h[1][0]) // (n - 2)
for i in range(2, n):
	if h[1][0] + c * (i - 1) != h[i][0]:
		break
else:
	print(h[0][1])
	exit()
c = (h[n - 2][0] - h[0][0]) // (n - 2)
for i in range(1, n - 1):
	if h[0][0] + c * i != h[i][0]:
		break
else:
	print(h[n - 1][1])
	exit()
c = (h[n - 1][0] - h[0][0]) // (n - 2)
i = 1
p = 1
cn = 0
while i < n:
	if h[0][0] + c * p != h[i][0]:
		p -= 1
		if cn == 1:
			cn += 1
			break
		j = i
		cn += 1
	i += 1
	p += 1
if cn == 1:
	print(h[j][1])
else:
	print(-1)


n = int(input())
l = list(map(int, input().split()))
mp = {}
for i in range(n):
	mp[l[i]] = i + 1
l.sort()

def AP(l):
	if len(l) == 1:
		return True
	d = l[1] - l[0]
	for i in range(2, len(l)):
		if d != l[i] - l[i - 1]:
			return False
	return True
if n <= 3:
	for i in range(n):
		if AP(l[:i] + l[i + 1:]):
			print(mp[l[i]])
			quit()
	print(-1)
else:
	dct = {}
	(D, cnt) = (-1, 0)
	for i in range(1, n):
		d = l[i] - l[i - 1]
		if d in dct:
			dct[d] += 1
		else:
			dct[d] = 1
	for i in dct:
		if dct[i] > cnt:
			D = i
			cnt = dct[i]
	for i in range(1, n):
		if l[i] - l[i - 1] != D:
			if AP(l[:i] + l[i + 1:]):
				print(mp[l[i]])
			elif AP(l[:i - 1] + l[i:]):
				print(mp[l[i - 1]])
			else:
				print(-1)
			break
	else:
		print(mp[l[0]])


def check(a, step, n):
	ind = 0
	i = 1
	while i < n:
		if a[i][0] - a[i - 1][0] != step:
			ind = i
			i += 1
			break
		i += 1
	if i >= n:
		return ind
	if a[i][0] - a[i - 2][0] == step:
		i += 1
	else:
		return -1
	while i < n:
		if a[i][0] - a[i - 1][0] != step:
			return -1
		i += 1
	return ind
n = int(input())
b = list(zip(list(map(int, input().split())), range(1, n + 1)))
b.sort(key=lambda x: x[0])
if n <= 3:
	print(1)
	exit(0)
step1 = b[1][0] - b[0][0]
step2 = b[2][0] - b[0][0]
step3 = b[2][0] - b[1][0]
step_diff = 0
ind = check(b, step1, n)
if ind != -1:
	print(b[ind][1])
	exit(0)
ind = check(b, step2, n)
if ind != -1:
	print(b[ind][1])
	exit(0)
for i in range(2, n):
	if b[i][0] - b[i - 1][0] != step3:
		print(-1)
		exit(0)
print(b[0][1])


n = int(input())
a = list(map(int, input().split()))
b = [(a[i], i + 1) for i in range(n)]
b.sort()

def is_ap(x):
	x = [x[i][0] - x[i - 1][0] for i in range(1, len(x))]
	return all((i == x[0] for i in x))
if is_ap(b[1:]):
	print(b[0][1])
	import sys
	sys.exit(0)
if is_ap(b[:-1]):
	print(b[-1][1])
	import sys
	sys.exit(0)
d = (b[-1][0] - b[0][0]) // (n - 2)
x = []
if b[0][0] + (n - 2) * d != b[-1][0]:
	x.append(1)
	x.append(2)
i = 1
while i < n:
	if b[i][0] - b[i - 1][0] == d:
		i += 1
		continue
	else:
		v = b[i - 1][0]
		while b[i][0] - v != d:
			x.append(b[i][1])
			i += 1
			if i >= n:
				x.append(1)
				break
		i += 1
if len(x) == 0:
	print(0)
elif len(x) == 1:
	print(x[0])
else:
	print(-1)


n = int(input())
A = list(map(int, input().split()))
if n == 2:
	print(1)
	exit(0)
elif n == 3:
	print(1)
	exit(0)
M = []
for i in range(n):
	A[i] = [A[i], i + 1]
A.sort()
for i in range(n - 1):
	M.append(A[i + 1][0] - A[i][0])
if len(set(M[1:])) == 1:
	print(A[0][1])
	exit(0)
if len(set(M[:-1])) == 1:
	print(A[-1][1])
	exit(0)
g = {}
for i in M:
	if i not in g:
		g[i] = 0
	g[i] += 1
for k in g:
	if g[k] >= n - 3:
		q = []
		for j in range(n - 1):
			if M[j] != k:
				q.append([M[j], j])
		if len(q) == 1:
			if q[0][0] == 0:
				print(A[q[0][1]][1])
				exit(0)
		if len(q) == 2:
			(a, b) = (q[0], q[1])
			if a[0] + b[0] == k:
				if abs(a[1] - b[1]) == 1:
					print(A[a[1] + 1][1])
					exit(0)
print(-1)


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())
a = list(map(int, input().split()))
for i in range(n):
	a[i] = (a[i], i)
a = sorted(a)
if n <= 3:
	print(1)
	exit()
diffs = {}
for i in range(1, n):
	d = a[i][0] - a[i - 1][0]
	if d not in diffs:
		diffs[d] = 1
	else:
		diffs[d] += 1
commonDiff = 0
times = 0
for (k, v) in diffs.items():
	if v > times:
		times = v
		commonDiff = k
if times < n - 3:
	print(-1)
	exit()
if n <= 5:
	commonDiff = -12345568989977
possible = [0]
for i in range(1, n):
	if a[i][0] - a[i - 1][0] != commonDiff:
		possible.append(i)
for k in possible:
	diffs = {}
	last = a[0][0]
	if k == 0:
		last = a[1][0]
	start = 1
	if k == 0:
		start = 2
	for i in range(start, n):
		if i == k:
			continue
		d = a[i][0] - last
		if d not in diffs:
			diffs[d] = 1
		else:
			diffs[d] += 1
		last = a[i][0]
	if len(diffs) == 1:
		print(a[k][1] + 1)
		exit()
print(-1)


n = int(input())
b = [int(x) for x in input().split()]
if n <= 3:
	print(1)
else:
	a = sorted(zip(b, range(n)))
	k1 = a[1][0] - a[0][0]
	k2 = a[3][0] - a[2][0]
	(mis1, mis2) = (None, None)
	(c1, c2) = (0, 0)
	for i in range(1, n):
		exp1 = a[0][0] + k1 * (i + (0 if c1 == 0 else -1))
		exp2 = a[0][0] + k2 * (i + (0 if c2 == 0 else -1))
		if exp1 != a[i][0]:
			c1 += 1
			mis1 = i
		if exp2 != a[i][0]:
			c2 += 1
			mis2 = i
	if c1 == 0:
		print(a[0][1] + 1)
	elif c1 == 1:
		print(a[mis1][1] + 1)
	elif c2 == 1:
		print(a[1][1] + 1)
	else:
		c2 = 0
		for i in range(2, n):
			exp2 = a[1][0] + k2 * (i - 1)
			if exp2 != a[i][0]:
				c2 += 1
				mis2 = i
		if c2 == 0:
			print(a[0][1] + 1)
		else:
			print(-1)


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

def progcheck1(A):
	for i in range(1, len(A) - 2):
		if A[i + 1] - A[i] != A[i + 2] - A[i + 1]:
			return False
	return True

def progchecklast(A):
	for i in range(len(A) - 3):
		if A[i + 1] - A[i] != A[i + 2] - A[i + 1]:
			return False
	return True

def progchecksecond(A):
	A = A.copy()
	A.remove(A[1])
	for i in range(len(A) - 2):
		if A[i + 1] - A[i] != A[i + 2] - A[i + 1]:
			return False
	return True
if progcheck1(b2) == True:
	print(b.index(b2[0]) + 1)
elif progchecklast(b2) == True:
	print(b.index(b2[-1]) + 1)
elif progchecksecond(b2) == True:
	print(b.index(b2[1]) + 1)
else:
	try:
		(tmp, res) = (0, 0)
		(c, c2) = [b2[1] - b2[0]] * 2
		for i in range(N - 1):
			if c != b2[i + 1] - b2[i]:
				tmp += 1
			if tmp > 2:
				break
			if c2 + b2[i + 1] - b2[i] == c and tmp == 2:
				res = b.index(b2[i])
			c2 = b2[i + 1] - b2[i]
		if tmp > 2 or res == 0:
			res = -2
		if tmp == 0:
			res = 0
	except:
		res = 0
	print(res + 1)


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict
import math
import heapq

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

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
n = intIn()
b = listIn()
if n <= 3:
	print(1)
	exit(0)
B = [(j, i) for (i, j) in enumerate(b)]
B = sorted(B)
(x, y, z) = (B[0][0], B[1][0], B[2][0])
(d1, d2, d3) = (y - x, z - x, z - y)
f = 1
for i in range(2, n):
	if B[i][0] != B[i - 1][0] + d3:
		f = 0
		break
if f:
	print(B[0][1] + 1)
	exit(0)
st = x
f = 1
for i in range(2, n):
	if i == 2:
		if B[i][0] != B[i - 2][0] + d2:
			f = 0
			break
	elif B[i][0] != B[i - 1][0] + d2:
		f = 0
		break
if f:
	print(B[1][1] + 1)
	exit(0)
li = []
st = y
for i in range(1, n):
	if B[i][0] != st:
		li.append(B[i])
	else:
		st += d1
if len(li) <= 1:
	print(li[0][1] + 1)
else:
	print(-1)


from collections import Counter

def check(b):
	diff_prog = [b[i] - b[i - 1] for i in range(1, len(b))]
	return len(set(diff_prog)) == 1

def main():
	n = int(input())
	original_b = [int(x) for x in input().split()]
	b = sorted(original_b)
	if check(b):
		return original_b.index(b[0]) + 1
	if check(b[1:]):
		return original_b.index(b[0]) + 1
	if check(b[:1] + b[2:]):
		return original_b.index(b[1]) + 1
	c = b[1] - b[0]
	index = 0
	for i in range(1, len(b)):
		if b[i] - b[i - 1] != c:
			index = i
			break
	if check(b[:index] + b[index + 1:]):
		return original_b.index(b[index]) + 1
	return -1
print(main())


import os
n = int(input())
a = [[int(x), idx] for (idx, x) in enumerate(input().split())]
a.sort(key=lambda x: x[0])
if len(a) == 2:
	print('1')
else:
	a1 = a[0][0]
	a2 = a[1][0]
	a3 = a[2][0]
	c1 = a2 - a1
	time = 0
	ans_idx = 0
	last = a1
	flag1 = True
	for i in range(1, len(a)):
		if a[i][0] != last + c1:
			if time == 0:
				ans_idx = i
				time += 1
			else:
				flag1 = False
				break
		else:
			last = a[i][0]
	if flag1 == True:
		print(a[ans_idx][1] + 1)
	c2 = a3 - a1
	last = a1
	flag2 = True
	for i in range(2, len(a)):
		if a[i][0] != last + c2:
			flag2 = False
			break
		else:
			last = a[i][0]
	if flag1 == False and flag2 == True:
		print(a[1][1] + 1)
	c3 = a3 - a2
	last = a2
	flag3 = True
	for i in range(2, len(a)):
		if a[i][0] != last + c3:
			flag3 = False
			break
		else:
			last = a[i][0]
	if flag1 == False and flag2 == False and (flag3 == True):
		print(a[0][1] + 1)
	if flag1 == False and flag2 == False and (flag3 == False):
		print('-1')


n = int(input())
l = list(map(int, input().split()))
idx = {}
for t in range(n):
	idx[l[t]] = t + 1
if n < 4:
	print(1)
else:
	l.sort()
	d = {}
	for t in range(1, n):
		d[l[t] - l[t - 1]] = d.get(l[t] - l[t - 1], 0) + 1
	if len(d) > 3:
		print(-1)
	elif len(d) == 1:
		print(idx[l[-1]])
	else:

		def check(L, dx):
			for i in range(1, len(L)):
				if L[i] - L[i - 1] != dx:
					return False
			return True

		def solve(cx):
			k = []
			for tc in l:
				k.append(tc)
			for j in range(1, n):
				if k[j] - k[j - 1] != cx:
					k2 = k[:j] + k[j + 1:]
					k1 = k[:j - 1] + k[j:]
					if check(k1, cx):
						print(idx[k[j - 1]])
						return 1
					elif check(k2, cx):
						print(idx[k[j]])
						return 1
					return 0
		for t in d:
			ans = solve(t)
			if ans == 1:
				exit()
		print(-1)


def check(v):
	d = v[1][0] - v[0][0]
	for i in range(1, len(v)):
		if v[i][0] - v[i - 1][0] != d:
			return False
	return True
n = int(input())
a = sorted(zip(map(int, input().split()), range(n)))
if n < 3:
	print(1)
elif check(a):
	print(a[0][1] + 1)
elif check(a[1:]):
	print(a[0][1] + 1)
elif check(a[:-1]):
	print(a[-1][1] + 1)
else:
	d = a[-1][0] - a[0][0]
	if d % (n - 2):
		print(-1)
	else:
		d //= n - 2
		b = []
		x = a[0][0]
		for i in range(1, n):
			if a[i][0] - x != d:
				b += (a[i][1] + 1,)
			else:
				x = a[i][0]
		if len(b) > 1:
			print(-1)
		else:
			print(b[0])


import math
n = int(input())
b = list(map(int, input().split()))
arr = sorted(b)
if arr[0] == arr[-1]:
	print(1)
	exit()
curr = arr[0]
if n == 2:
	print(1)
	exit()
cc = 0
d = arr[1] - arr[0]
nn = 1
element = []
for i in range(1, n):
	temp = curr + nn * d
	if temp == arr[i]:
		nn += 1
	else:
		element.append(arr[i])
		cc += 1
if len(element) == 1:
	print(b.index(element[0]) + 1)
	exit()
if cc == 0:
	print(b.index(arr[0]) + 1)
	exit()
curr = arr[1]
e1 = []
d = arr[2] - arr[1]
cc = 0
nn = 1
for i in range(2, n):
	temp = curr + nn * d
	if temp == arr[i]:
		nn += 1
		continue
	else:
		cc += 1
		e1.append(arr[i])
if cc == 0:
	print(b.index(arr[0]) + 1)
	exit()
d = arr[2] - arr[0]
curr = arr[0]
element = -1
cc = 0
nn = 1
for i in range(2, n):
	temp = curr + nn * d
	if temp == arr[i]:
		nn += 1
		continue
	else:
		cc += 1
if cc == 0:
	print(b.index(arr[1]) + 1)
	exit()
print(-1)


import math
import sys

def check(d):
	t = d[1] - d[0]
	for i in range(2, len(d)):
		if d[i] - d[i - 1] != t:
			return False
	return True
n = int(input())
d = list(map(int, input().split()))
sd = sorted(d)
if n == 2:
	exit(print(1))
if n <= 5:
	for i in range(n):
		t = d[:]
		t.remove(d[i])
		if check(sorted(t)):
			exit(print(i + 1))
	exit(print(-1))
f = sd[0]
l = sd[-1]
if check(sd[1:]):
	exit(print(d.index(f) + 1))
if check(sd[:-1]):
	exit(print(d.index(l) + 1))
dif = []
for i in range(1, n):
	dif.append(sd[i] - sd[i - 1])
t = {}
c = -1
m = 0
for i in dif:
	if i in t:
		t[i] += 1
	else:
		t[i] = 1
	if t[i] > m:
		m = t[i]
		c = i
if m != n - 3:
	print(-1)
else:
	r = 0
	pair = []
	for i in t:
		if i != c:
			r += i * t[i]
			pair.append(i)
	if pair[0] + pair[1] == c:
		print(d.index(sd[dif.index(pair[0]) + 1]) + 1)
	else:
		print(-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)


def naiveSolve():
	return
from collections import Counter

def main():
	n = int(input())
	a = readIntArr()
	if n <= 3:
		print(1)
		return
	b = []
	for (i, x) in enumerate(a):
		b.append([x, i])
	b.sort()
	cd = Counter()
	for i in range(1, n):
		d = b[i][0] - b[i - 1][0]
		cd[d] += 1
	if len(cd.keys()) > 3:
		print(-1)
		return
	ans = -1
	for i in range(n):
		if i - 1 >= 0:
			d = b[i][0] - b[i - 1][0]
			cd[d] -= 1
		if i + 1 < n:
			d = b[i + 1][0] - b[i][0]
			cd[d] -= 1
		if i - 1 >= 0 and i + 1 < n:
			d = b[i + 1][0] - b[i - 1][0]
			cd[d] += 1
		nonZeroCnts = 0
		for (k, v) in cd.items():
			if v > 0:
				nonZeroCnts += 1
		if nonZeroCnts == 1:
			ans = b[i][1] + 1
			break
		if i - 1 >= 0:
			d = b[i][0] - b[i - 1][0]
			cd[d] += 1
		if i + 1 < n:
			d = b[i + 1][0] - b[i][0]
			cd[d] += 1
		if i - 1 >= 0 and i + 1 < n:
			d = b[i + 1][0] - b[i - 1][0]
			cd[d] -= 1
	print(ans)
	return
import sys
input = sys.stdin.buffer.readline

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

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

def makeArr(defaultValFactory, dimensionArr):
	dv = defaultValFactory
	da = dimensionArr
	if len(da) == 1:
		return [dv() for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(l, r):
	print('? {} {}'.format(l, r))
	sys.stdout.flush()
	return int(input())

def answerInteractive(x):
	print('! {}'.format(x))
	sys.stdout.flush()
inf = float('inf')
MOD = 998244353
from math import gcd, floor, ceil
for _abc in range(1):
	main()


import collections
n = int(input())
zi = list(map(int, input().split()))
bi = list(sorted(zi))
dp = [0] * (n - 1)

def checkIsAP(arr, n):
	if n == 1:
		return True
	d = arr[1] - arr[0]
	for i in range(2, n):
		if arr[i] - arr[i - 1] != d:
			return False
	return True
if n == 2:
	print(1)
else:
	for i in range(1, n):
		dp[i - 1] = bi[i] - bi[i - 1]
	pss1 = 0
	pss2 = 0
	pss3 = 0
	for i in range(n - 2):
		if dp[i] != dp[i + 1]:
			if i == 0:
				pss1 = 0
				pss2 = 1
				pss3 = 2
			elif i == n - 3:
				pss1 = n - 1
				pss2 = n - 2
				pss3 = n - 3
			else:
				pss1 = i + 1
				pss2 = i
				pss3 = i + 2
	xi = bi.copy()
	xi.pop(pss1)
	if checkIsAP(xi, len(xi)):
		print(zi.index(bi[pss1]) + 1)
	else:
		xi = bi.copy()
		xi.pop(pss2)
		if checkIsAP(xi, len(xi)):
			print(zi.index(bi[pss2]) + 1)
		else:
			xi = bi.copy()
			xi.pop(pss3)
			if checkIsAP(xi, len(xi)):
				print(zi.index(bi[pss3]) + 1)
			else:
				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())
arr = list(map(int, input().split()))
brr = []
brr = arr.copy()
arr.sort()
mp = {}
maxi = -1
for i in range(1, n):
	diff = arr[i] - arr[i - 1]
	if diff in mp:
		mp[diff] += 1
	else:
		mp[diff] = 1
ans = -1
for i in range(n):
	if i == 0:
		if len(mp) == 1:
			ans = i
			break
		diff = arr[i + 1] - arr[i]
		buf = mp[diff]
		if mp[diff] == 1:
			mp.pop(diff)
			if len(mp) == 1:
				ans = i
				break
			mp[diff] = buf
	elif i == n - 1:
		diff = arr[i] - arr[i - 1]
		buf = mp[diff]
		if mp[diff] == 1:
			mp.pop(diff)
			if len(mp) == 1:
				ans = i
				break
			mp[diff] = buf
	else:
		diff1 = arr[i + 1] - arr[i]
		diff2 = arr[i] - arr[i - 1]
		buf1 = mp[diff1]
		buf2 = mp[diff2]
		diff3 = diff2 + diff1
		if diff1 == diff2:
			if mp[diff1] == 2:
				mp.pop(diff1)
				if diff3 in mp:
					if len(mp) == 1:
						ans = i
						break
				mp[diff1] = 2
		else:
			if mp[diff1] == 1:
				mp.pop(diff1)
			if mp[diff2] == 1:
				mp.pop(diff2)
			if diff3 in mp:
				if len(mp) <= 1:
					ans = i
					break
			mp[diff1] = buf1
			mp[diff2] = buf2
if ans == -1:
	print(-1)
else:
	for j in range(n):
		if brr[j] == arr[ans]:
			print(j + 1)
			break


import sys

def checkIsAP(arr, n):
	if n == 1:
		return True
	arr.sort()
	d = arr[1] - arr[0]
	for i in range(2, n):
		if arr[i] - arr[i - 1] != d:
			return False
	return True
n = int(input())
l = list(map(int, input().split()))
cop = [l[i] for i in range(n)]
it = l.index(max(l))
it1 = l.index(min(l))
l.sort()
if checkIsAP(l[1:], n - 1) == True:
	print(it1 + 1)
	sys.exit()
elif checkIsAP(l[:n], n - 1) == True:
	print(it + 1)
	sys.exit()
elif checkIsAP(l, n) == True:
	print(1)
	sys.exit()
dif = [0] * (n - 1)
ci = [0] * (n - 1)
for i in range(n - 1):
	dif[i] = l[i + 1] - l[i]
	ci[i] = dif[i]
dif.sort()
count = dif.count(dif[n // 2])
if count == n - 3:
	su = 0
	e = []
	for j in range(n - 1):
		if dif[j] != dif[n // 2]:
			su += dif[j]
			e.append(dif[j])
	if su == dif[n // 2]:
		ind = 0
		for j in range(n - 2):
			if ci[j] == e[0] and ci[j + 1] == e[1]:
				ind = j + 1
				break
			if ci[j] == e[1] and ci[j + 1] == e[0]:
				ind = j + 1
				break
		ind = cop.index(l[ind])
		print(ind + 1)
	else:
		print(-1)
elif count == n - 2 and dif.count(0) == 1:
	for j in range(n - 2):
		if ci[j] == 0:
			ind = j + 1
			break
	ind = cop.index(l[ind])
	print(ind + 1)
else:
	print(-1)


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
n = int(input())
l = list(map(int, input().split()))
l = [[l[i], i] for i in range(n)]
if len(l) == 2:
	print(1)
	exit()
if len(l) == 3:
	print(2)
	exit()
l.sort()
d = l[1][0] - l[0][0]
seti = set()
for i in range(1, n - 1):
	seti.add(l[i + 1][0] - l[i][0])
if len(seti) == 1:
	print(l[0][1] + 1)
	exit()
flag = 0
ha = set()
ans = -1
for i in range(1, n - 1):
	z = l[i + 1][0] - l[i][0]
	if i + 1 in ha:
		continue
	if z != d and flag == 0:
		flag = 1
		if i + 2 < n:
			if l[i + 2][0] - l[i][0] == d:
				ha.add(i + 2)
				ans = l[i + 1][1] + 1
			else:
				ans = l[i][1] + 1
				ha.add(i + 1)
		else:
			ans = l[i + 1][1] + 1
			ha.add(i + 2)
	elif z != d and flag == 1:
		flag = 2
		break
if flag == 1:
	z = list(ha)[0]
	l.remove(l[z - 1])
	d = l[1][0] - l[0][0]
	for i in range(1, len(l) - 1):
		if l[i + 1][0] - l[i][0] != d:
			print(-1)
			exit()
	print(ans)
	exit()
l.reverse()
d = l[1][0] - l[0][0]
flag = 0
ha = set()
for i in range(1, n - 1):
	z = l[i + 1][0] - l[i][0]
	if i + 1 in ha:
		continue
	if z != d and flag == 0:
		flag = 1
		if i + 2 < n:
			if l[i + 2][0] - l[i][0] == d:
				ha.add(i + 2)
				ans = l[i + 1][1] + 1
			else:
				ans = l[i][1] + 1
				ha.add(i + 1)
		else:
			ans = l[i + 1][1] + 1
			ha.add(i + 2)
	elif z != d and flag == 1:
		print(-1)
		exit()
z = list(ha)[0]
l.remove(l[z - 1])
d = l[1][0] - l[0][0]
for i in range(1, len(l) - 1):
	if l[i + 1][0] - l[i][0] != d:
		print(-1)
		exit()
print(ans)
exit()


import sys
input = sys.stdin.readline
from collections import defaultdict

def check(l):
	d = l[1] - l[0]
	for i in range(1, len(l) - 1):
		if d != l[i + 1] - l[i]:
			return False
	return True
n = int(input())
b = list(map(int, input().split()))
idx = defaultdict(int)
for i in range(n):
	idx[b[i]] = i + 1
b.sort()
if check(b):
	print(idx[b[0]])
	exit()
if check(b[1:]):
	print(idx[b[0]])
	exit()
if check([b[0]] + b[2:]):
	print(idx[b[1]])
	exit()
d = b[1] - b[0]
removed = False
i = 0
while i < n - 1:
	if removed and d != b[i + 1] - b[i]:
		print(-1)
		exit()
	if not removed and d != b[i + 1] - b[i]:
		if i == n - 2:
			print(idx[b[n - 1]])
			exit()
		if d != b[i + 2] - b[i]:
			print(-1)
			exit()
		removed = True
		ans = idx[b[i + 1]]
		i += 2
	else:
		i += 1
print(ans)


import os
import sys
from io import BytesIO, IOBase
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')
from collections import defaultdict
n = int(input())
vals = list(map(int, input().split()))
tot = sum(vals)
vals = [(vals[s], s) for s in range(n)]
vals.sort()
if n <= 3:
	print(1)
elif n <= 5:
	vals.sort()
	num = -1
	for i in range(n):
		arr = []
		for s in range(n):
			if s != i:
				arr.append(vals[s][0])
		setty = set([])
		for s in range(1, n - 1):
			setty.add(arr[s] - arr[s - 1])
		if len(setty) == 1:
			num = vals[i][1] + 1
			break
	print(num)
else:
	occ = defaultdict(int)
	most = 0
	num = -1
	for s in range(1, n):
		d = vals[s][0] - vals[s - 1][0]
		occ[d] += 1
		if occ[d] > most:
			most = occ[d]
			num = d
	number = -1
	for s in range(n):
		if s == 0:
			a_k = vals[1][0]
		else:
			a_k = vals[0][0]
		summy = (n - 1) * a_k + num * ((n - 1) * (n - 2)) // 2
		if summy == tot - vals[s][0]:
			arr = []
			count = 0
			for i in range(n):
				if s != i:
					arr.append(vals[i][0])
			for i in range(1, n - 1):
				if arr[i] - arr[i - 1] == num:
					count += 1
			if count == n - 2:
				number = vals[s][1] + 1
				break
	print(number)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
n = iinp()
arr = lmp()
if n < 4:
	print(1)
else:
	sarr = sorted(arr)
	x = sarr[1] - sarr[0]
	flg = True
	for i in range(2, n - 1):
		if sarr[i] - sarr[i - 1] != x:
			flg = False
			break
	if flg:
		print(arr.index(sarr[-1]) + 1)
	else:
		x = sarr[2] - sarr[1]
		flg = True
		for i in range(2, n):
			if sarr[i] - sarr[i - 1] != x:
				flg = False
				break
		if flg:
			print(arr.index(sarr[0]) + 1)
		else:
			mx = 0
			for i in range(1, n):
				mx = max(mx, sarr[i] - sarr[i - 1])
			flg = True
			k = sarr[-1]
			for i in range(1, n):
				if sarr[i] - sarr[i - 1] != mx:
					if i == n - 1 or sarr[i + 1] - sarr[i - 1] == mx:
						k = sarr[i]
						sarr.pop(i)
					else:
						flg = False
					break
			if not flg:
				print(-1)
			else:
				s = set()
				for i in range(1, len(sarr)):
					s.add(sarr[i] - sarr[i - 1])
				if len(s) != 1:
					print(-1)
				else:
					print(arr.index(k) + 1)


from collections import defaultdict

def f():
	global aa
	if n <= 3:
		return 1
	if n <= 7:
		for i in range(n):
			b = []
			for j in range(n):
				if j != i:
					b.append(aa[j])
			s = set()
			for j in range(1, n - 1):
				s.add(b[j] - b[j - 1])
			if len(s) == 1:
				return i + 1
		return -1
	c = defaultdict(int)
	d = defaultdict(list)
	s = set()
	for i in range(1, n):
		x = aa[i] - aa[i - 1]
		s.add(x)
		c[x] += 1
		d[x].append(i)
	cnt = len(s)
	if cnt > 3:
		return -1
	if cnt == 1:
		return 1
	if cnt == 2:
		(a, b) = s
		if c[a] < c[b]:
			(a, b) = (b, a)
		if c[b] == 1:
			if d[b][0] == 1:
				return 1
			elif d[b][0] == n - 1:
				return n
		elif c[b] == 2:
			if abs(d[b][0] - d[b][1]) == 1 and a == b + b:
				return max(d[b])
			else:
				return -1
		else:
			return -1
	if cnt == 3:
		(x, y, z) = s
		if c[y] >= c[x] and c[y] >= c[z]:
			(x, y, z) = (y, x, z)
		elif c[z] >= c[x] and c[z] >= c[y]:
			(x, y, z) = (z, x, y)
		if c[y] != 1 and c[z] != 1:
			return -1
		v1 = d[y][0]
		v2 = d[z][0]
		if abs(v1 - v2) == 1:
			if y + z == x:
				return max(v1, v2)
			else:
				return -1
		else:
			return -1
n = int(input())
x = input().split()
b = []
for i in range(n):
	b.append((int(x[i]), i + 1))
b.sort()
aa = []
for el in b:
	aa.append(el[0])
try:
	r = f()
	if r == -1:
		print(-1)
	else:
		print(b[r - 1][1])
except Exception:
	print(-1)


n = int(input())
a2 = list(map(int, input().split()))
a = sorted(a2)
a1 = a[:n - 1]
a1.append(a[n - 1])
a.pop(0)
if len(a) == 1:
	print(1)
else:
	d = a[1] - a[0]
	k = True
	for i in range(2, len(a)):
		if a[i] - a[i - 1] != d:
			k = False
	if k == True:
		print(a2.index(a1[0]) + 1)
	else:
		k = True
		a = a1[:n - 1]
		a.append(a1[n - 1])
		a.pop(1)
		d = a[1] - a[0]
		for i in range(2, len(a)):
			if a[i] - a[i - 1] != d:
				k = False
		if k == True:
			print(a2.index(a1[1]) + 1)
		else:
			a = a1[:n - 1]
			a.append(a1[n - 1])
			d = a[1] - a[0]
			k = True
			f = True
			o = 0
			for i in range(2, len(a)):
				if a[i] - a[i - 1] != d:
					o = a2.index(a[i])
					a.pop(i)
					break
			for i in range(1, len(a)):
				if a[i] - a[i - 1] != d:
					f = False
					break
			if f == False:
				print(-1)
			else:
				print(o + 1)


from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
sted = sorted(arr)
dd = [0] * (n - 1)
for i in range(n - 1):
	dd[i] = sted[i + 1] - sted[i]
c = Counter(dd)

def indexit(num):
	for i in range(n):
		if arr[i] == num:
			return i + 1

def could(i):
	b = dd[i - 1]
	a = dd[i]
	su = a + b
	c[a] -= 1
	c[b] -= 1
	c[su] += 1
	if c[a] == 0:
		del c[a]
	if c[b] == 0:
		del c[b]
	ans = len(c) == 1
	c[a] += 1
	c[b] += 1
	c[su] -= 1
	if c[su] == 0:
		del c[su]
	return ans

def solution():
	if len(c) == 1:
		return indexit(sted[-1])
	else:
		for i in range(1, n - 1):
			if could(i):
				return indexit(sted[i])
		f = dd[0]
		c[f] -= 1
		if c[f] == 0:
			del c[f]
		if len(c) == 1:
			return indexit(sted[0])
		c[f] += 1
		l = dd[-1]
		c[l] -= 1
		if c[l] == 0:
			del c[l]
		if len(c) == 1:
			return indexit(sted[-1])
		return -1
print(solution())


import copy
import sys
from heapq import heappush, heappop
sys.setrecursionlimit(1000000)

class Main:

	def __init__(self):
		self.buff = None
		self.index = 0

	def next(self):
		if self.buff is None or self.index == len(self.buff):
			self.buff = self.next_line()
			self.index = 0
		val = self.buff[self.index]
		self.index += 1
		return val

	def next_line(self):
		return sys.stdin.readline().split()

	def next_ints(self):
		return [int(x) for x in sys.stdin.readline().split()]

	def next_int(self):
		return int(self.next())

	def solve(self):
		n = self.next_int()
		x = sorted([(i + 1, v) for (i, v) in enumerate(self.next_ints())], key=lambda y: y[1])
		if len(x) <= 3:
			print(1)
		else:
			xx = copy.deepcopy(x)
			rr = xx.pop(0)[0]
			if self.test(xx):
				print(rr)
			else:
				xx = copy.deepcopy(x)
				rr = xx.pop(1)[0]
				if self.test(xx):
					print(rr)
				else:
					i = 0
					j = 1
					rr = x[n - 1][0]
					for k in range(2, n):
						if x[j][1] * 2 == x[i][1] + x[k][1]:
							i = j
							j = k
						elif rr != x[n - 1][0]:
							print(-1)
							return
						else:
							rr = x[k][0]
					print(rr)

	def test(self, xx):
		i = 0
		j = 1
		for k in range(2, len(xx)):
			if xx[j][1] * 2 != xx[i][1] + xx[k][1]:
				return False
			i = j
			j = k
		return True
Main().solve()


def check(arr):
	d = arr[1] - arr[0]
	for i in range(len(arr) - 1):
		if arr[i] + d != arr[i + 1]:
			return False
	return True
n = int(input())
arr = list(map(int, input().split()))
ls = sorted(arr)
if n == 2:
	print(1)
	exit()
if check(ls[1:]):
	print(arr.index(ls[0]) + 1)
	exit(0)
if check([ls[0]] + ls[2:]):
	print(arr.index(ls[1]) + 1)
	exit(0)
d = ls[1] - ls[0]
ind = 0
for i in range(n - 1):
	if ls[i] + d != ls[i + 1]:
		ind = i + 1
		break
if check(ls[:ind] + ls[ind + 1:]):
	print(arr.index(ls[ind]) + 1)
	exit(0)
else:
	print(-1)


from collections import Counter
n = int(input())
ls = list(map(int, input().split()))
copy = list(ls)
ls.sort()
arr = []
for i in range(n - 1):
	arr.append(ls[i + 1] - ls[i])
d = dict(Counter(arr))
M = max(d.values())
for (k, v) in d.items():
	if v == M:
		break
cur = k
diff = []
for i in range(n - 1):
	if arr[i] != cur:
		diff.append((i, arr[i]))
if len(arr) == 3 and len(set(arr)) == 3:
	if arr[0] + arr[1] == arr[2] or arr[0] + arr[2] == arr[1] or arr[1] + arr[2] == arr[0]:
		delete = ls[1]
		for i in range(n):
			if copy[i] == delete:
				print(i + 1)
				break
	else:
		print(-1)
elif len(diff) > 2:
	print(-1)
elif diff == []:
	delete = ls[0]
	for i in range(n):
		if copy[i] == delete:
			print(i + 1)
			break
elif len(diff) == 2 and diff[0][1] + diff[1][1] == cur and (diff[0][0] + 1 == diff[1][0]):
	delete = ls[diff[1][0]]
	for i in range(n):
		if copy[i] == delete:
			print(i + 1)
			break
elif len(diff) == 2:
	print(-1)
else:
	delete = diff[0][0]
	if 0 == delete or diff[0][1] == 0:
		for i in range(n):
			if copy[i] == ls[delete]:
				print(i + 1)
				break
	elif n - 2 == delete:
		delete = ls[-1]
		for i in range(n):
			if copy[i] == delete:
				print(i + 1)
				break
	else:
		print(-1)


from sys import stdin, setrecursionlimit
setrecursionlimit(10 ** 7)

def iin():
	return int(stdin.readline())

def lin():
	return list(map(int, stdin.readline().split()))

def main():
	n = iin()
	a = [[j, i + 1] for (i, j) in enumerate(lin())]
	a.sort()
	if n <= 3:
		print(1)
	else:
		sa = set()
		for i in range(2, n):
			(x, y) = a[i]
			sa.add(x - a[i - 1][0])
		if len(sa) == 1:
			print(a[0][1])
		else:
			sa = set()
			for i in range(1, n - 1):
				sa.add(a[i][0] - a[i - 1][0])
			if len(sa) == 1:
				print(a[-1][1])
			else:
				d = (a[-1][0] - a[0][0]) / (n - 2)
				if int(d * 1000) != int(d) * 1000:
					print(-1)
				else:
					d = int(d)
					nsl = []
					ns = set()
					invans = 0
					for i in range(1, n - 1):
						if i - 1 in ns:
							continue
						if a[i][0] - a[i - 1][0] != d or a[i + 1][0] - a[i][0] != d:
							if a[i + 1][0] - a[i - 1][0] == d:
								nsl.append(i)
								ns.add(i)
							else:
								invans = 1
					if len(nsl) > 1 or (invans and len(nsl) != 1):
						print(-1)
					elif len(nsl) == 0:
						print(1)
					else:
						print(a[nsl[0]][1])
main()


import copy

def check(n, b, i):
	newb = copy.deepcopy(b)
	poppd = newb.pop(i)
	newb.sort()
	cd = newb[1] - newb[0]
	for x in range(len(newb) - 1):
		if newb[x + 1] - newb[x] != cd:
			return False
	return True

def doit(n, b):
	arr = []
	for x in range(n):
		arr.append([b[x], x])
	arr.sort()
	cd = arr[1][0] - arr[0][0]
	last = 1
	for x in range(n - 2):
		if cd != arr[x + 1][0] - arr[x][0]:
			last = 0
			break
	if last == 1:
		return arr[-1][1] + 1
	cd = arr[2][0] - arr[1][0]
	first = 1
	for y in range(1, n - 1):
		if cd != arr[y + 1][0] - arr[y][0]:
			first = 0
			break
	if first == 1:
		return arr[0][1] + 1
	cd_arr = []
	for g in range(n - 1):
		cd_arr.append(arr[g + 1][0] - arr[g][0])
	d = {}
	for h in range(len(cd_arr)):
		if cd_arr[h] not in d:
			d[cd_arr[h]] = 1
		else:
			d[cd_arr[h]] += 1
	if len(d) > 3:
		return -1
	else:
		ctr = 0
		elem = 0
		for k in d:
			if d[k] > ctr:
				ctr = d[k]
				elem = k
		answer = 0
		complete = 0
		for p in range(len(cd_arr)):
			if cd_arr[p] != elem:
				answer = p + 1
				bl = check(n, b, arr[p + 1][1])
				if bl == True:
					complete = 1
					break
		if complete == 1:
			return arr[p + 1][1] + 1
		return -1
n = int(input())
b = [int(i) for i in input().split()]
if n == 2:
	print(1)
elif n == 3:
	print(1)
elif n == 4:
	arr = []
	for x in range(n):
		arr.append([b[x], x])
	arr.sort()
	if arr[2][0] - arr[1][0] == arr[3][0] - arr[2][0]:
		print(arr[0][1] + 1)
	elif arr[2][0] - arr[0][0] == arr[3][0] - arr[2][0]:
		print(arr[1][1] + 1)
	elif arr[1][0] - arr[0][0] == arr[3][0] - arr[1][0]:
		print(arr[2][1] + 1)
	elif arr[1][0] - arr[0][0] == arr[2][0] - arr[1][0]:
		print(arr[3][1] + 1)
	else:
		print(-1)
elif n == 5:
	arr = []
	for x in range(n):
		arr.append([b[x], x])
	arr.sort()
	if arr[2][0] - arr[1][0] == arr[3][0] - arr[2][0] == arr[4][0] - arr[3][0]:
		print(arr[0][1] + 1)
	elif arr[2][0] - arr[0][0] == arr[3][0] - arr[2][0] == arr[4][0] - arr[3][0]:
		print(arr[1][1] + 1)
	elif arr[1][0] - arr[0][0] == arr[3][0] - arr[1][0] == arr[4][0] - arr[3][0]:
		print(arr[2][1] + 1)
	elif arr[1][0] - arr[0][0] == arr[2][0] - arr[1][0] == arr[4][0] - arr[2][0]:
		print(arr[3][1] + 1)
	elif arr[1][0] - arr[0][0] == arr[2][0] - arr[1][0] == arr[3][0] - arr[2][0]:
		print(arr[4][1] + 1)
	else:
		print(-1)
else:
	print(doit(n, b))


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())

def checkap(arr):
	d = arr[1] - arr[0]
	for i in range(len(arr) - 1):
		if arr[i] + d != arr[i + 1]:
			return False
	return True

def main():
	n = ii()
	l = il()
	arr = sorted(l)
	if checkap(arr) or checkap(arr[1:]):
		print(l.index(arr[0]) + 1)
		exit(0)
	if checkap(arr[:1] + arr[2:]):
		print(l.index(arr[1]) + 1)
		exit(0)
	d = arr[1] - arr[0]
	ind = -1
	for i in range(n - 1):
		if arr[i] + d != arr[i + 1]:
			ind = i + 1
			break
	if checkap(arr[:ind] + arr[ind + 1:]):
		print(l.index(arr[ind]) + 1)
	else:
		print(-1)
main()


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
decimal.getcontext().prec = 46

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def modefiedSieve():
	mx = 10 ** 7 + 1
	sieve = [-1] * mx
	for i in range(2, mx):
		if sieve[i] == -1:
			sieve[i] = i
			for j in range(i * i, mx, i):
				if sieve[j] == -1:
					sieve[j] = i
	return sieve

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def DFS(n, s, adj):
	visited = [False for i in range(n + 1)]
	stack = []
	stack.append(s)
	while len(stack):
		s = stack[-1]
		stack.pop()
		if not visited[s]:
			visited[s] = True
		for node in adj[s]:
			if not visited[node]:
				stack.append(node)

def maxSubArraySum(a, size):
	maxint = 10 ** 10
	max_so_far = -maxint - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

def solve():
	n = int(input())
	arr = list_input()
	position = {}
	for i in range(n):
		position[arr[i]] = i
	arr.sort()
	flag = True
	prev = -1
	ans = position[arr[-1]] + 1
	for i in range(n - 1):
		if arr[i] == '.':
			continue
		diff = arr[i + 1] - arr[i]
		if prev == -1:
			prev = diff
			continue
		if prev != diff:
			if i + 1 == n - 1:
				if flag:
					print(position[arr[i + 1]] + 1)
				else:
					print(-1)
				return
			if flag:
				flag = False
				if arr[i + 2] - arr[i] == prev:
					ans = position[arr[i + 1]] + 1
					arr[i + 1] = '.'
				elif diff == arr[i + 2] - arr[i + 1]:
					if i - 2 <= 0:
						if i - 2 == 0:
							if diff == arr[i] - arr[i - 2]:
								ans = position[arr[i - 1]] + 1
								prev = diff
							else:
								print(-1)
								return
						else:
							ans = position[arr[i - 1]] + 1
							prev = diff
					else:
						print(-1)
						return
				elif arr[i + 2] - arr[i + 1] == arr[i + 1] - arr[i - 1]:
					ans = position[arr[i]] + 1
					prev = arr[i + 2] - arr[i + 1]
				else:
					print(-1)
					return
			else:
				print(-1)
				return
	print(ans)
t = 1
for _ in range(t):
	solve()


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


a = int(input())
start = [int(x) for x in input().split()]
s = sorted(start)
if a < 3:
	print(1)
else:
	key = True
	may = s[2] - s[1]
	for i in range(1, a - 1):
		if s[i + 1] - s[i] != may:
			key = False
			break
	if key:
		print(start.index(s[0]) + 1)
	else:
		sc = s.copy()
		it = sc.pop(1)
		may = sc[1] - sc[0]
		key = True
		for i in range(a - 2):
			if sc[i + 1] - sc[i] != may:
				key = False
				break
		if key:
			print(start.index(it) + 1)
		else:
			sc = s.copy()
			ifjump = False
			may = s[1] - s[0]
			key = True
			cnt = False
			for i in range(a - 1):
				if cnt:
					cnt = False
					continue
				if sc[i + 1] - sc[i] != may:
					if not ifjump:
						ifjump = True
						cnt = True
						ans = sc[i + 1]
						if i == a - 2:
							break
						elif sc[i + 2] - sc[i] != may:
							key = False
							break
					else:
						key = False
						break
			if key:
				print(start.index(ans) + 1)
			else:
				print(-1)


import sys

def check(a):
	d = [a[i] - a[i - 1] for i in range(1, len(a))]
	c = d[0]
	return all((di == c for di in d))
n = int(input())
b = list(map(int, input().split()))
b = [(b[i], i + 1) for i in range(n)]
b.sort()
(a, p) = ([b[i][0] for i in range(n)], [b[i][1] for i in range(n)])
if n <= 3:
	print(1)
	sys.exit(0)
if check(a):
	print(p[0])
	sys.exit(0)
if check(a[1:]):
	print(p[0])
	sys.exit(0)
aa = [a[0]]
aa.extend(a[2:])
if check(aa):
	print(p[1])
	sys.exit(0)
d = [a[i] - a[i - 1] for i in range(1, len(a))]
idx = 0
while d[idx] == d[0]:
	idx += 1
aa = a[:idx + 1]
aa.extend(a[idx + 2:])
if check(aa):
	print(p[idx + 1])
else:
	print(-1)


import sys
import math
import collections
import heapq
import decimal
input = sys.stdin.readline
n = int(input())
l = [int(i) for i in input().split()]
s = set()
l1 = sorted(l)
for i in range(1, n):
	s.add(l1[i] - l1[i - 1])
if len(s) == 1:
	for i in range(n):
		if l[i] == l1[0]:
			print(i + 1)
			break
else:
	s3 = set()
	for i in range(2, n):
		s3.add(l1[i] - l1[i - 1])
	if len(s3) == 1:
		for i in range(n):
			if l[i] == l1[0]:
				print(i + 1)
				break
	else:
		s3 = set()
		for i in range(1, n - 1):
			s3.add(l1[i] - l1[i - 1])
		if len(s3) == 1:
			for i in range(n):
				if l[i] == l1[n - 1]:
					print(i + 1)
					break
		elif len(s) > 3:
			print(-1)
		elif len(s) == 3:
			s1 = sorted(s)
			if s1[0] + s1[1] == s1[2]:
				k = -1
				for i in range(1, n):
					if l1[i] - l1[i - 1] == s1[0]:
						k = i
						break
				s2 = set()
				for i in range(1, k):
					s2.add(l1[i] - l1[i - 1])
				if k == n - 1:
					if len(s2) == 1:
						for i in range(n):
							if l[i] == l1[k]:
								print(i + 1)
								break
					else:
						k = -1
						for i in range(1, n):
							if l1[i] - l1[i - 1] == s1[1]:
								k = i
								break
						s2 = set()
						for i in range(1, k):
							s2.add(l1[i] - l1[i - 1])
						if k == n - 1:
							if len(s2) == 1:
								for i in range(n):
									if l[i] == l1[k]:
										print(i + 1)
										break
							else:
								print(-1)
						else:
							s2.add(l1[k + 1] - l1[k - 1])
							for j in range(k + 2, n):
								s2.add(l1[j] - l1[j - 1])
							if len(s2) == 1:
								for i in range(n):
									if l[i] == l1[k]:
										print(i + 1)
										break
							else:
								print(-1)
				else:
					s2.add(l1[k + 1] - l1[k - 1])
					for j in range(k + 2, n):
						s2.add(l1[j] - l1[j - 1])
					if len(s2) == 1:
						for i in range(n):
							if l[i] == l1[k]:
								print(i + 1)
								break
					else:
						k = -1
						for i in range(1, n):
							if l1[i] - l1[i - 1] == s1[1]:
								k = i
								break
						s2 = set()
						for i in range(1, k):
							s2.add(l1[i] - l1[i - 1])
						if k == n - 1:
							if len(s2) == 1:
								for i in range(n):
									if l[i] == l1[k]:
										print(i + 1)
										break
							else:
								print(-1)
						else:
							s2.add(l1[k + 1] - l1[k - 1])
							for j in range(k + 2, n):
								s2.add(l1[j] - l1[j - 1])
							if len(s2) == 1:
								for i in range(n):
									if l[i] == l1[k]:
										print(i + 1)
										break
							else:
								print(-1)
			else:
				print(-1)
		else:
			s1 = sorted(s)
			if s1[0] == 0:
				c = 0
				k = -1
				for i in range(1, n):
					if l1[i] - l1[i - 1] == 0:
						k = i
						c += 1
				if c > 1:
					print(-1)
				else:
					for i in range(n):
						if l[i] == l1[k]:
							print(i + 1)
							break
			elif 2 * s1[0] == s1[1]:
				k = -1
				for i in range(1, n):
					if l1[i] - l1[i - 1] == s1[0]:
						k = i
						break
				s2 = set()
				for i in range(1, k):
					s2.add(l1[i] - l1[i - 1])
				if k == n - 1:
					if len(s2) == 1:
						for i in range(n):
							if l[i] == l1[k]:
								print(i + 1)
								break
					else:
						print(-1)
				else:
					s2.add(l1[k + 1] - l1[k - 1])
					for j in range(k + 2, n):
						s2.add(l1[j] - l1[j - 1])
					if len(s2) == 1:
						for i in range(n):
							if l[i] == l1[k]:
								print(i + 1)
								break
					else:
						print(-1)
			else:
				print(-1)


countdiff = {}
n = int(input())
arr = list(map(int, input().split()))
arr1 = sorted(arr)
for i in range(1, len(arr1)):
	tmp = arr1[i] - arr1[i - 1]
	if tmp in countdiff:
		countdiff[tmp] += 1
	else:
		countdiff[tmp] = 1
searchval = 10 ** 9 + 1
for i in range(len(arr)):
	if i == 0:
		diff = arr1[i + 1] - arr1[i]
		countdiff[diff] -= 1
		if countdiff[diff] == 0:
			countdiff.pop(diff)
		if len(countdiff) == 1:
			searchval = arr1[i]
			break
		elif diff in countdiff:
			countdiff[diff] += 1
		else:
			countdiff[diff] = 1
	elif i < len(arr) - 1:
		diff1 = arr1[i] - arr1[i - 1]
		diff2 = arr1[i + 1] - arr1[i]
		countdiff[diff1] -= 1
		if countdiff[diff1] == 0:
			countdiff.pop(diff1)
		countdiff[diff2] -= 1
		if countdiff[diff2] == 0:
			countdiff.pop(diff2)
		diff3 = arr1[i + 1] - arr1[i - 1]
		if diff3 in countdiff:
			countdiff[diff3] += 1
		else:
			countdiff[diff3] = 1
		if len(countdiff) == 1:
			searchval = arr1[i]
			break
		else:
			if diff1 in countdiff:
				countdiff[diff1] += 1
			else:
				countdiff[diff1] = 1
			if diff2 in countdiff:
				countdiff[diff2] += 1
			else:
				countdiff[diff2] = 1
			if countdiff[diff3] == 1:
				countdiff.pop(diff3)
			else:
				countdiff[diff3] -= 1
	else:
		diff = arr1[i] - arr1[i - 1]
		countdiff[diff] -= 1
		if countdiff[diff] == 0:
			countdiff.pop(diff)
		if len(countdiff) == 1:
			searchval = arr1[i]
			break
		elif diff in countdiff:
			countdiff[diff] += 1
		else:
			countdiff[diff] = 1
if len(arr) == 2 or len(arr) == 3:
	print(1)
elif searchval == 10 ** 9 + 1:
	print(-1)
else:
	print(arr.index(searchval) + 1)


import itertools
n = int(input())
b = list(map(int, input().split()))
c = sorted(b)
diff = []
for i in range(n - 1):
	diff.append(c[i + 1] - c[i])
diff_val = diff[:]
diff = itertools.groupby(diff)
diff_list = []
for (key, group) in diff:
	diff_list.append([key, len(list(group))])
if len(diff_list) == 1:
	print(b.index(c[0]) + 1)
elif len(diff_list) == 2:
	if diff_list[0][1] == 1:
		print(b.index(c[0]) + 1)
	elif diff_list[1][1] == 1:
		print(b.index(c[-1]) + 1)
	elif diff_list[0][1] == 2 and diff_list[0][0] * 2 == diff_list[1][0]:
		print(b.index(c[1]) + 1)
	elif diff_list[1][1] == 2 and diff_list[1][0] * 2 == diff_list[0][0]:
		print(b.index(c[-2]) + 1)
	else:
		print(-1)
elif len(diff_list) == 3:
	if diff_list[0][0] == diff_list[2][0] and diff_list[1][1] == 2 and (diff_list[1][0] * 2 == diff_list[0][0]):
		x = diff_list[1][0]
		for i in range(len(diff_val)):
			if diff_val[i] == x:
				print(b.index(c[i + 1]) + 1)
				break
	elif diff_list[1][1] == 1:
		if diff_list[0][0] + diff_list[1][0] == diff_list[2][0]:
			x = diff_list[1][0]
			for i in range(len(diff_val)):
				if diff_val[i] == x:
					print(b.index(c[i]) + 1)
					break
		elif diff_list[2][0] + diff_list[1][0] == diff_list[0][0]:
			x = diff_list[1][0]
			for i in range(len(diff_val)):
				if diff_val[i] == x:
					print(b.index(c[i + 1]) + 1)
					break
		else:
			print(-1)
	else:
		print(-1)
elif len(diff_list) == 4:
	if diff_list[1][1] == diff_list[2][1] and diff_list[1][1] == 1 and (diff_list[0][0] == diff_list[3][0]) and (diff_list[1][0] + diff_list[2][0] == diff_list[0][0]):
		x = diff_list[1][0]
		for i in range(len(diff_val)):
			if diff_val[i] == x:
				print(b.index(c[i + 1]) + 1)
				break
	else:
		print(-1)
else:
	print(-1)


import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
B = sorted(A)
if len(B) <= 3:
	print(1)
	sys.exit()
x = B[2] - B[1]
for i in range(2, n):
	if B[i] - B[i - 1] == x:
		continue
	else:
		break
else:
	print(A.index(B[0]) + 1)
	sys.exit()
y = B[2] - B[0]
for i in range(3, n):
	if B[i] - B[i - 1] == y:
		continue
	else:
		break
else:
	print(A.index(B[1]) + 1)
	sys.exit()
z = B[1] - B[0]
ANS = []
i = 2
while i < n:
	if B[i] - B[i - 1] != z:
		if i < n - 1 and B[i + 1] - B[i - 1] == z:
			ANS.append(i)
			i += 2
		elif i == n - 1:
			ANS.append(i)
			i += 1
		else:
			print(-1)
			sys.exit()
	else:
		i += 1
	if len(ANS) > 1:
		print(-1)
		sys.exit()
print(A.index(B[ANS[0]]) + 1)


def check(l):
	res = set()
	for i in range(len(l) - 1):
		res.add(l[i + 1] - l[i])
	return len(res) == 1
input()
nums = list(map(int, input().split()))
dic = {}
for (idx, num) in enumerate(nums):
	dic[num] = idx + 1
nums.sort()
if check(nums):
	print(dic[nums[0]])
	exit(0)
elif check(nums[1:]):
	print(dic[nums[0]])
	exit(0)
elif check(nums[:1] + nums[2:]):
	print(dic[nums[1]])
	exit(0)
d = nums[1] - nums[0]
for i in range(2, len(nums)):
	if nums[i] - nums[i - 1] != d:
		if check(nums[:i] + nums[i + 1:]):
			print(dic[nums[i]])
		else:
			print(-1)
		exit(0)


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)


n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
d = dict()
for i in range(n - 1):
	dif = b[i + 1] - b[i]
	if dif in d:
		d[dif] += 1
	else:
		d[dif] = 1
key = -1
ind = 3000000000
flag = 0
for (k, v) in d.items():
	if d[k] >= n - 3:
		flag = 1
		if k > key:
			key = k
if n <= 3:
	print(1)
elif flag == 1:
	if b[1] - b[0] != key and b[n - 1] - b[n - 2] == key and (b[2] - b[1] == key):
		ind = b[0]
	elif b[n - 1] - b[n - 2] != key and b[1] - b[0] == key and (b[n - 2] - b[n - 3] == key):
		ind = b[n - 1]
	elif len(d) == 1:
		ind = b[0]
	else:
		for i in range(1, n - 1):
			if b[i] - b[i - 1] != key and b[i + 1] - b[i] != key or (b[i - 1] == b[i] and b[i] - b[i - 1] != key):
				ind = b[i]
				flag = 0
				break
	if (flag == 1 or b[b.index(ind) + 1] - b[b.index(ind) - 1] == key) and ind != 3000000000:
		print(a.index(ind) + 1)
	else:
		print(-1)
else:
	print(-1)


def Check_Ap(a):
	d = a[1] - a[0]
	for i in range(len(a) - 1):
		if a[i] + d != a[i + 1]:
			return False
	return True
n = int(input())
array = list(map(int, input().split()))
arr = sorted(array)
if Check_Ap(arr) or Check_Ap(arr[1:]):
	print(array.index(arr[0]) + 1)
	exit(0)
if Check_Ap([arr[0]] + arr[2:]):
	print(array.index(arr[1]) + 1)
	exit(0)
ind = None
d = arr[1] - arr[0]
for i in range(n - 1):
	if arr[i] + d != arr[i + 1]:
		ind = i + 1
		break
if Check_Ap(arr[:ind] + arr[ind + 1:]):
	print(array.index(arr[ind]) + 1)
else:
	print(-1)


from sys import stdin, stdout
from collections import Counter
n = int(stdin.readline().strip())
seq = list(map(int, stdin.readline().strip().split(' ')))
if n <= 3:
	stdout.write('1')
else:
	sortmap = zip(seq, [i + 1 for i in range(len(seq))])
	sortmap = sorted(sortmap)
	seq = [x for (x, _) in sortmap]
	sortmap = [x for (_, x) in sortmap]
	diff = []
	d = {}
	for i in range(1, len(seq)):
		diff.append(seq[i] - seq[i - 1])
		if diff[-1] in d:
			d[diff[-1]] += 1
		else:
			d[diff[-1]] = 1
	flag = True
	d[diff[0]] -= 1
	ansi = -1
	for i in d:
		if d[i] == len(diff) - 1:
			ansi = sortmap[0]
			flag = False
			break
	d[diff[0]] += 1
	for i in range(1, len(seq) - 1):
		d[diff[i - 1]] -= 1
		d[diff[i]] -= 1
		if diff[i] + diff[i - 1] in d:
			d[diff[i] + diff[i - 1]] += 1
		else:
			d[diff[i] + diff[i - 1]] = 1
		if d[diff[i] + diff[i - 1]] == len(diff) - 1:
			ansi = sortmap[i]
			flag = False
			d[diff[i - 1]] += 1
			d[diff[i]] += 1
			d[diff[i] + diff[i - 1]] -= 1
			break
		d[diff[i - 1]] += 1
		d[diff[i]] += 1
		d[diff[i] + diff[i - 1]] -= 1
	d[diff[-1]] -= 1
	for i in d:
		if d[i] == len(diff) - 1:
			ansi = sortmap[-1]
			flag = False
			break
	d[diff[-1]] += 1
	if flag:
		stdout.write('-1')
	else:
		stdout.write(str(ansi))


import copy

def check(nums, index, d):
	new = copy.deepcopy(nums)
	new.pop(index)
	for i in range(1, len(new)):
		if new[i][0] - new[i - 1][0] != d:
			return False
	return True

def main():
	n = int(input())
	nums = list(map(int, input().split()))
	if n <= 3:
		print(1)
		return
	nums1 = []
	for i in range(n):
		nums1.append([nums[i], i + 1])
	nums1.sort()
	nums = nums1
	d_count = {}
	for i in range(1, n):
		d1 = nums[i][0] - nums[i - 1][0]
		if d1 not in d_count.keys():
			d_count[d1] = 1
		else:
			d_count[d1] += 1
	if len(d_count) > 3:
		print(-1)
		return
	if len(d_count) == 1:
		print(nums[0][1])
		return
	max_count = 0
	d = 0
	for i in d_count.keys():
		if d_count[i] > max_count:
			max_count = d_count[i]
			d = i
	for i in d_count.keys():
		if d_count[i] == max_count:
			d = max(d, i)
	index = -1
	for i in range(1, n):
		d1 = nums[i][0] - nums[i - 1][0]
		if d1 != d:
			if index != -1:
				print(-1)
				return
			if check(nums, i, d):
				index = nums[i][1]
				if i + 1 < len(nums):
					nums[i][0] = nums[i + 1][0] - d
			elif check(nums, i - 1, d):
				index = nums[i - 1][1]
			else:
				print(-1)
				return
	print(index)
main()


from collections import defaultdict
n = int(input())
l = list(map(int, input().split()))
y = l[0]
l1 = []
for i in range(n):
	l1.append([l[i], i])
l1.sort()
l.sort()
d = defaultdict(int)
for i in range(1, n):
	d[l[i] - l[i - 1]] += 1
if len(d) > 3:
	print(-1)
elif len(d) == 3:
	l2 = []
	x = 0
	if n > 4:
		for i in d:
			if d[i] == n - 3:
				x = i
			else:
				l2.append(i)
		if l2[0] + l2[1] == x and d[l2[0]] == d[l2[1]] == 1:
			ans = False
			for i in range(1, n - 1):
				if l[i] - l[i - 1] != x and l[i + 1] - l[i] != x:
					ans = l1[i][1] + 1
					break
			if ans != False:
				print(ans)
			else:
				print(-1)
		else:
			print(-1)
	elif l[2] - l[1] == l[3] - l[2]:
		print(l1[0][1] + 1)
	elif l[2] - l[0] == l[3] - l[2]:
		print(l1[1][1] + 1)
	elif l[1] - l[0] == l[3] - l[1]:
		print(l1[2][1] + 1)
	elif l[1] - l[0] == l[2] - l[1]:
		print(l1[3][1] + 1)
	else:
		print(-1)
elif len(d) == 2:
	l2 = []
	for i in d:
		l2.append(i)
	l2.sort()
	if 2 * l2[0] == l2[1] and d[l2[0]] == 2:
		ans = False
		for i in range(1, n - 1):
			if l[i] - l[i - 1] != l2[1] and l[i + 1] - l[i] != l2[1]:
				ans = l1[i][1] + 1
				break
		if ans != False:
			print(ans)
		else:
			print(-1)
	elif n == 3:
		print(1)
	elif l[1] - l[0] != l[2] - l[1] and d[l[1] - l[0]] == 1:
		print(l1[0][1] + 1)
	elif l[-1] - l[-2] != l[-2] - l[-3] and d[l[-1] - l[-2]] == 1:
		print(l1[-1][1] + 1)
	elif d[0] == 1:
		for i in range(1, n):
			if l[i] == l[i - 1]:
				ans = l1[i][1] + 1
				break
		print(ans)
	else:
		print(-1)
else:
	print(l1[0][1] + 1)


n = int(input())
a = [int(i) for i in input().split()]
good = 0
f = True
indexes = {}
x = len(set(a))
for i in range(n):
	indexes[a[i]] = i + 1
if x == 1:
	good = a[-1]
elif x != n:
	bad = []
	counts = {}
	for i in a:
		if i in counts.keys():
			counts[i] += 1
		else:
			counts[i] = 1
		if counts[i] >= 2 and i not in bad:
			bad.append(i)
	if len(bad) >= 2:
		f = False
	elif counts[bad[0]] == 2:
		new = []
		for i in a:
			if i == bad[0]:
				if i not in new:
					new.append(i)
			else:
				new.append(i)
		new.sort()
		ideal = new[0] - new[1]
		for i in range(1, len(new) - 1):
			if new[i] - new[i + 1] != ideal:
				f = False
		if f:
			good = bad[0]
	elif counts[bad[0]] == n - 1:
		for i in counts.keys():
			if i != bad[0]:
				good = i
	else:
		f = False
else:
	a.sort()
	steps = [0] * (n - 1)
	count_steps = {}
	M_steps = set()
	for i in range(n - 1):
		steps[i] = a[i] - a[i + 1]
		M_steps.add(a[i] - a[i + 1])
		if a[i] - a[i + 1] in count_steps.keys():
			count_steps[a[i] - a[i + 1]] += 1
		else:
			count_steps[a[i] - a[i + 1]] = 1
		if len(M_steps) > 3:
			f = False
			break
	if f:
		count_steps = list(count_steps.items())
		count_steps.sort(key=lambda x: -x[0])
		count_steps.sort(key=lambda x: x[1])
		if len(M_steps) == 1:
			good = a[-1]
		else:
			ideal = count_steps[-1][0]
			bad_indexes = []
			for i in range(len(steps)):
				if steps[i] != ideal:
					bad_indexes.append(i)
			if len(bad_indexes) > 2:
				f = False
			elif len(bad_indexes) == 1:
				if bad_indexes[0] == 0:
					good = a[0]
				else:
					good = a[-1]
			elif abs(bad_indexes[0] - bad_indexes[1]) != 1:
				f = False
			elif -(a[max(bad_indexes) + 1] - a[min(bad_indexes)]) != ideal:
				f = False
			else:
				good = a[max(bad_indexes)]
if f:
	print(indexes[good])
else:
	print(-1)


def solve():
	N = int(input())
	B = list(map(int, input().split()))
	if N == 2:
		return 1
	C = B[:]
	C.sort()
	D = [c2 - c1 for (c1, c2) in zip(C, C[1:])]
	x = B.index(C[0])
	if check(x, B):
		return x + 1
	x = B.index(C[1])
	if check(x, B):
		return x + 1
	pre = D[0]
	bp1 = -1
	for j in range(N):
		if pre != D[j]:
			bp1 = j
			break
	if bp1 == -1:
		return 1
	x = B.index(C[bp1 + 1])
	if check(x, B):
		return x + 1
	return -1

def check(i, B):
	if not 0 <= i < len(B):
		return False
	SB = B[:i] + B[i + 1:]
	SB.sort()
	SB = [c2 - c1 for (c1, c2) in zip(SB, SB[1:])]
	if len(set(SB)) == 1:
		return True
	return False
print(solve())


n = int(input())
brr = list(map(int, input().split()))
arr = []
for i in range(n):
	arr.append([brr[i], i])
arr.sort()
d = [-1, -1, -1]
ind = [-1, -1, -1]
for i in range(1, n):
	x = arr[i][0] - arr[i - 1][0]
	if x == d[0] or d[0] == -1:
		d[0] = x
		ind[0] = i
	elif x == d[1] or d[1] == -1:
		d[1] = x
		ind[1] = i
	elif x == d[2] or d[2] == -1:
		d[2] = x
		ind[2] = i

def func(ans):
	temp = set()
	for i in range(1, len(ans)):
		temp.add(ans[i][0] - ans[i - 1][0])
	f = False
	if len(temp) == 1:
		f = True
	return not temp or f
f = 0
for i in ind:
	x = arr[:i] + arr[i + 1:]
	y = arr[:i - 1] + arr[i:]
	ans1 = func(x)
	ans2 = func(y)
	if ans1 == True:
		f = 1
		print(arr[i][1] + 1)
		break
	elif ans2 == True:
		f = 1
		print(arr[i - 1][1] + 1)
		break
if f == 0:
	print(-1)


def gns():
	return list(map(int, input().split()))
n = int(input())
ns = gns()
wh = {}
for i in range(n):
	wh[ns[i]] = i
ns.sort()

def check(ns):
	ans = True
	if len(ns) <= 3:
		return True
	c = ns[2] - ns[1]
	for i in range(3, n):
		if ns[i] - ns[i - 1] != c:
			ans = False
			break
	if ans:
		return 0
	ans = True
	c = ns[2] - ns[0]
	for i in range(3, n):
		if ns[i] - ns[i - 1] != c:
			ans = False
			break
	if ans:
		return 1
	ans = True
	c = ns[1] - ns[0]
	num = 0
	last = ns[1]
	for i in range(2, n):
		if ns[i] - last != c:
			if num > 0:
				ans = -1
				break
			else:
				ans = i
				num += 1
				continue
		else:
			last = ns[i]
	return ans
ith = check(ns)
if ith == -1:
	print(-1)
	quit()
print(wh[ns[ith]] + 1)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
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')
n = int(input())
b = list(map(int, input().split()))
a = list()
for i in range(n):
	a.append((b[i], i + 1))
a.sort()
s = set()
d = list()
dc = dict()
for i in range(1, n):
	diff = a[i][0] - a[i - 1][0]
	if diff in dc:
		dc[diff] += 1
	else:
		dc[diff] = 1
	if diff in s:
		continue
	s.add(diff)
	d.append(diff)
if len(s) == 1 or n <= 3:
	print(a[-1][1])
elif len(s) > 3:
	print(-1)
elif len(s) == 2:
	d.sort()
	if dc[d[0]] == 1 or dc[d[1]] == 1:
		if dc[d[0]] == 1:
			f = d[0]
		else:
			f = d[1]
		if a[1][0] - a[0][0] == f:
			print(a[0][1])
		elif a[n - 1][0] - a[n - 2][0] == f:
			print(a[-1][1])
		elif f == 0:
			ch = -1
			for i in range(1, n):
				if a[i][0] == a[i - 1][0]:
					ch = a[i][1]
					break
			print(ch)
		else:
			print(-1)
	elif dc[d[0]] == 2 and 2 * d[0] == d[1]:
		ch = -1
		for i in range(1, n - 1):
			if a[i][0] - a[i - 1][0] == a[i + 1][0] - a[i][0] == d[0]:
				ch = a[i][1]
				break
		print(ch)
	else:
		print(-1)
else:
	d.sort()
	if d[0] + d[1] != d[2]:
		print(-1)
	elif dc[d[0]] == dc[d[1]] == 1:
		ch = -1
		for i in range(1, n - 1):
			if a[i][0] - a[i - 1][0] == d[0] and a[i + 1][0] - a[i][0] == d[1] or (a[i][0] - a[i - 1][0] == d[1] and a[i + 1][0] - a[i][0] == d[0]):
				ch = a[i][1]
				break
		print(ch)


from sys import stdin, stdout, exit
from collections import defaultdict
n = int(stdin.readline())
a = [(int(s), i) for (i, s) in enumerate(stdin.readline().split())]

def maj(l):
	cts = defaultdict(int)
	for x in l:
		cts[x] += 1
	best_seen = 0
	best = 0
	for (x, ct) in cts.items():
		if ct > best:
			best_seen = x
			best = ct
	return best_seen

def is_ap(l):
	if len(l) == 1:
		return True
	d = l[1] - l[0]
	return all([l[i + 1] - l[i] == d for i in range(len(l) - 1)])
a.sort()
b = [x for (x, i) in a]
if n <= 6:
	for i in range(n):
		if is_ap(b[:i] + b[i + 1:]):
			print(a[i][1] + 1)
			exit()
	print(-1)
	exit()
ds = [b[i + 1] - b[i] for i in range(n - 1)]
d = maj(ds)
if is_ap(b[1:]):
	print(a[0][1] + 1)
	exit()
for i in range(n - 1):
	if b[i + 1] - b[i] != d:
		if is_ap(b[:i + 1] + b[i + 2:]):
			print(a[i + 1][1] + 1)
		else:
			print(-1)
		exit()


n = int(input())
if n <= 3:
	print(1)
else:
	originalVals = [int(x) for x in input().split()]
	l = originalVals[:]
	l.sort()
	stillOneToThrow = True
	pos = True
	thrownVal = l[0]
	currentVal = 2
	if l[1] - l[0] != l[3] - l[2]:
		stillOneToThrow = False
		if l[2] - l[1] == l[3] - l[2]:
			thrownVal = l[0]
			l.pop(0)
		elif l[2] - l[0] == l[3] - l[2]:
			thrownVal = l[1]
			l.pop(1)
		elif l[3] - l[1] == l[1] - l[0]:
			thrownVal = l[2]
			l.pop(2)
		elif l[2] - l[1] == l[1] - l[0]:
			thrownVal = l[3]
			l.pop(3)
		else:
			pos = False
	if pos:
		diff = l[1] - l[0]
		while currentVal < len(l):
			if l[currentVal] - l[currentVal - 1] != diff:
				if stillOneToThrow:
					thrownVal = l[currentVal]
					l.pop(currentVal)
					stillOneToThrow = False
				else:
					pos = False
					break
			else:
				currentVal += 1
	if pos:
		print(originalVals.index(thrownVal) + 1)
	else:
		print(-1)


from math import *
import sys
input = sys.stdin.readline
n = int(input())
ap = [int(x) for x in input().split()]
a = sorted(ap)
flag = 0
d = []
for i in range(1, n):
	if len(d) == 0:
		d.append([a[i], -9 * 10 ** 12, 0, [a[i]]])
		d.append([a[i - 1], -9 * 10 ** 12, 0, [a[i - 1]]])
		d.append([a[i], a[i] - a[i - 1], 1, [a[i - 1], a[i]]])
	else:
		zist = 0
		for j in range(len(d)):
			if d[j][1] == -9 * 10 ** 12:
				d[j][1] = a[i] - d[j][0]
				d[j][0] = a[i]
				d[j][2] += 1
				d[j][3].append(a[i])
				zist = 1
			elif d[j][1] == a[i] - d[j][0]:
				d[j][0] = a[i]
				d[j][2] += 1
				d[j][3].append(a[i])
				zist = 1
		if zist != 1:
			flag += 1
			z = a[i]
		if flag == 2:
			break
if flag == 2:
	print(-1)
	exit(0)
flag = 0
for i in range(len(d)):
	if d[i][2] >= n - 2:
		flag = 1
		z = i
		break
if flag == 0:
	print(-1)
	exit(0)
p = sorted(d[z][3])
for i in range(len(p)):
	if a[i] != p[i]:
		p = [a[i]]
		break
if len(p) > 1:
	p = [a[n - 1]]
for i in range(n):
	if ap[i] == p[0]:
		break
print(i + 1 if len(p) == 1 else n)


from sys import exit

def isg(a):
	d = a[1][0] - a[0][0]
	for i in range(2, len(a)):
		if a[i][0] - a[i - 1][0] != d:
			return False
	return True
n = int(input())
if n <= 3:
	print(1)
	exit()
a = sorted([[int(e), i] for (i, e) in enumerate(input().split())])
if isg(a[1:]):
	print(a[0][1] + 1)
	exit()
if isg([a[0]] + a[2:]):
	print(a[1][1] + 1)
	exit()
m = a[1][0] - a[0][0]
for i in range(2, n):
	if a[i][0] - a[i - 1][0] != m:
		if isg(a[:i] + a[i + 1:]):
			print(a[i][1] + 1)
		else:
			print(-1)
		exit()


n = int(input())
arr0 = list(map(int, input().split()))
arr = sorted(arr0)

def is_ap(a):
	d = a[1] - a[0]
	for i in range(len(a) - 1):
		if a[i] + d != a[i + 1]:
			return False
	return True
if is_ap(arr) or is_ap(arr[1:]):
	print(arr0.index(arr[0]) + 1)
	exit(0)
if is_ap([arr[0]] + arr[2:]):
	print(arr0.index(arr[1]) + 1)
	exit(0)
d = arr[1] - arr[0]
skip = None
for i in range(len(arr) - 1):
	if arr[i] + d != arr[i + 1]:
		skip = i + 1
		break
assert skip != None
if is_ap(arr[:skip] + arr[skip + 1:]):
	print(arr0.index(arr[skip]) + 1)
else:
	print(-1)


def check(xs, i):
	del xs[i]
	if not xs or len(xs) <= 2:
		return True
	p = xs[1]
	d = xs[1] - xs[0]
	for x in xs[2:]:
		if x - p != d:
			return False
		p = x
	return True
n = int(input())
bs = list(map(int, input().split()))
m = {}
for (i, b) in enumerate(bs):
	m[b] = i + 1
bs.sort()
if check(bs[:], 0):
	print(m[bs[0]])
	exit(0)
for i in range(1, n - 1):
	if bs[i] - bs[i - 1] != bs[i + 1] - bs[i]:
		if check(bs[:], i - 1):
			print(m[bs[i - 1]])
		elif check(bs[:], i):
			print(m[bs[i]])
		elif check(bs[:], i + 1):
			print(m[bs[i + 1]])
		else:
			print(-1)
		exit(0)


import math
from collections import deque, defaultdict
from sys import stdin, stdout
input = stdin.readline
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())

def check(a):
	if len(a) == 1:
		return True
	d = a[1] - a[0]
	for i in range(1, len(a)):
		if a[i] - a[i - 1] != d:
			return False
	return True
n = int(input())
a = listin()
z = [i for i in a]
a.sort()
if check(a) or check(a[1:]):
	print(z.index(a[0]) + 1)
	exit()
elif check([a[0]] + a[2:]):
	print(z.index(a[1]) + 1)
	exit()
d = a[1] - a[0]
k = 0
for i in range(n - 1):
	if a[i + 1] - a[i] != d:
		k = i + 1
		break
if check(a[:k] + a[k + 1:]):
	print(z.index(a[k]) + 1)
else:
	print(-1)


n = int(input())
arr = [(int(x), i) for (i, x) in enumerate(input().split())]
arr.sort()

def check(arr_temp):
	diff = [arr_temp[i][0] - arr_temp[i - 1][0] for i in range(1, n - 1)]
	return not diff or diff.count(diff[0]) == len(diff)
(d1, d2, d3) = (-1, -1, -1)
(idx1, idx2, idx3) = (-1, -1, -1)
for i in range(1, n):
	if arr[i][0] - arr[i - 1][0] == d1 or d1 == -1:
		d1 = arr[i][0] - arr[i - 1][0]
		idx1 = i
	elif arr[i][0] - arr[i - 1][0] == d2 or d2 == -1:
		d2 = arr[i][0] - arr[i - 1][0]
		idx2 = i
	elif arr[i][0] - arr[i - 1][0] == d3 or d3 == -1:
		d3 = arr[i][0] - arr[i - 1][0]
		idx3 = i
for i in [idx1, idx2, idx3]:
	if check(arr[:i] + arr[i + 1:]):
		print(arr[i][1] + 1)
		break
	elif check(arr[:i - 1] + arr[i:]):
		print(arr[i - 1][1] + 1)
		break
else:
	print(-1)


from copy import deepcopy
n = int(input())
a = list(map(int, input().split()))
a = [(a[i], i) for i in range(n)]
a.sort(key=lambda x: x[0])
diff = {}
for i in range(1, len(a)):
	if a[i][0] - a[i - 1][0] not in diff:
		diff[a[i][0] - a[i - 1][0]] = 0
	diff[a[i][0] - a[i - 1][0]] += 1
if len(diff) == 1:
	print(a[0][1] + 1)
elif len(diff) > 3:
	print(-1)
else:
	ind = -1
	for i in range(0, len(a)):
		temp = deepcopy(diff)
		if i == 0:
			temp[a[i + 1][0] - a[i][0]] -= 1
			if temp[a[i + 1][0] - a[i][0]] == 0:
				del temp[a[i + 1][0] - a[i][0]]
			if len(temp) == 1:
				ind = a[i][1] + 1
				break
		elif i == n - 1:
			temp[a[i][0] - a[i - 1][0]] -= 1
			if temp[a[i][0] - a[i - 1][0]] == 0:
				del temp[a[i][0] - a[i - 1][0]]
			if len(temp) == 1:
				ind = a[i][1] + 1
				break
		else:
			temp[a[i][0] - a[i - 1][0]] -= 1
			temp[a[i + 1][0] - a[i][0]] -= 1
			if temp[a[i + 1][0] - a[i][0]] == 0:
				del temp[a[i + 1][0] - a[i][0]]
			if a[i][0] - a[i - 1][0] in temp and temp[a[i][0] - a[i - 1][0]] == 0:
				del temp[a[i][0] - a[i - 1][0]]
			if a[i + 1][0] - a[i - 1][0] not in temp:
				temp[a[i + 1][0] - a[i - 1][0]] = 0
			temp[a[i + 1][0] - a[i - 1][0]] += 1
			if len(temp) == 1:
				ind = a[i][1] + 1
				break
	print(ind)


a = int(input())
from collections import defaultdict
t = list(map(int, input().split()))
z = []
for i in range(len(t)):
	z.append([t[i], i])
z.sort()
al = defaultdict(int)
ans = []
for i in range(1, len(z)):
	ans.append(z[i][0] - z[i - 1][0])
if a <= 3:
	print(1)
elif ans.count(ans[1]) == len(ans) - 1 and ans[0] != ans[1]:
	print(z[0][1] + 1)
elif ans.count(ans[0]) == len(ans) - 1 and ans[-1] != ans[0]:
	print(z[-1][1] + 1)
elif ans.count(ans[0]) == len(ans):
	print(z[0][1] + 1)
elif len(ans) == 3:
	if ans[0] + ans[1] == ans[2]:
		print(2)
		exit()
	elif ans[1] + ans[2] == ans[0]:
		print(3)
		exit()
	print(-1)
else:
	maxa = 0
	index = 0
	for i in range(len(ans)):
		al[ans[i]] += 1
		if al[ans[i]] > maxa:
			maxa = al[ans[i]]
			index = ans[i]
		elif al[ans[i]] == maxa:
			if ans[i] > index:
				index = ans[i]
	if maxa == len(ans) - 2:
		for i in range(len(ans)):
			if ans[i] != index:
				if ans[i] + ans[i + 1] == index and ans[i + 1] != index:
					print(z[i + 1][1] + 1)
					exit()
				else:
					print(-1)
					exit()
	elif maxa == len(ans) - 1:
		for i in range(len(ans)):
			if ans[i] != index and ans[i] == 0:
				print(z[i + 1][1] + 1)
				exit()
	print(-1)


def is_d(a):
	d = a[1] - a[0]
	for i in range(len(a) - 1):
		if a[i] + d != a[i + 1]:
			return False
	return True
n = int(input())
a = list(map(int, input().split()))
a_s = sorted(a)
if is_d(a_s) or is_d(a_s[1:]):
	print(a.index(a_s[0]) + 1)
	exit()
if is_d([a_s[0]] + a_s[2:]):
	print(a.index(a_s[1]) + 1)
	exit()
d = a_s[1] - a_s[0]
c = False
for i in range(len(a_s) - 1):
	if a_s[i] + d != a_s[i + 1]:
		c = i + 1
		break
if is_d(a_s[:c] + a_s[c + 1:]):
	print(a.index(a_s[c]) + 1)
else:
	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
n = int(input())
orig = [(int(x), i) for (i, x) in enumerate(input().split())]
A = sorted(orig)
n = len(A)
if n == 2:
	print(1)
	sys.exit()
diffs = []
for i in range(1, n):
	diffs.append(A[i][0] - A[i - 1][0])
diffs = set(diffs)
if len(diffs) > 3:
	print(-1)
	sys.exit()

def inc(d, A):
	skipped = []
	last = A[0][0]
	for ii in range(1, len(A)):
		(a, i) = A[ii]
		if a - last != d:
			skipped.append(i)
			if len(skipped) >= 2:
				return None
		else:
			last = a
	return skipped[0] if skipped else A[0][1]
revA = A[::-1]

def dec(d, A):
	return inc(-d, revA)
for d in diffs:
	i = inc(d, A)
	if i != None:
		print(i + 1)
		sys.exit()
	i = dec(d, revA)
	if i != None:
		print(i + 1)
		sys.exit()
print(-1)


N = int(input())
A = [int(a) for a in input().split()]
INV = {}
for i in range(N):
	INV[A[i]] = i
A = sorted(A)

def chk(k):
	X = [a for a in A]
	if k >= 0:
		del X[k]
	Y = [X[i + 1] - X[i] for i in range(len(X) - 1)]
	if max(Y) == min(Y):
		return INV[A[k]] + 1
	return -1

def solve():
	if N <= 3:
		return 1
	else:
		a = A[1] - A[0]
		b = A[2] - A[1]
		c = A[3] - A[2]
		if a == b == c:
			for i in range(len(A) - 1):
				if A[i + 1] - A[i] != a:
					return chk(i + 1)
		return max(chk(0), chk(1), chk(2), chk(3))
print(solve())


def main():
	buf = input()
	n = int(buf)
	buf = input()
	buflist = buf.split()
	if n == 2 or n == 3:
		print(1)
		return
	b = list(map(int, buflist))
	for i in range(n):
		b[i] = (b[i], i)
	b.sort()
	delta = []
	for i in range(n - 1):
		delta.append(b[i + 1][0] - b[i][0])
	deltamap = dict()
	for x in delta:
		if x in deltamap:
			deltamap[x] += 1
		else:
			deltamap[x] = 1
	if len(deltamap) == 1:
		print(b[0][1] + 1)
		return
	zero_candidate = []
	norm_candidate = []
	for (k, v) in deltamap.items():
		if v == n - 2:
			zero_candidate.append(k)
		elif v == n - 3:
			norm_candidate.append(k)
	if zero_candidate:
		if delta[0] != zero_candidate[0]:
			print(b[0][1] + 1)
			return
		elif delta[-1] != zero_candidate[0]:
			print(b[-1][1] + 1)
			return
		elif 0 in deltamap:
			if zero_candidate[0] == 0:
				print(-1)
				return
			for (i, x) in enumerate(delta):
				if x == 0:
					print(b[i][1] + 1)
					return
		print(-1)
		return
	elif norm_candidate:
		if 0 in deltamap:
			print(-1)
			return
		for x in norm_candidate:
			for i in range(n - 2):
				if delta[i] + delta[i + 1] == x:
					print(b[i + 1][1] + 1)
					return
		print(-1)
		return
	else:
		print(-1)
		return
main()


def ans(ind):
	arr = []
	for i in range(n):
		if i != ind:
			arr.append(a[i])
	arr.sort(reverse=True)
	ok = True
	if len(arr) == 1:
		return ok
	checksum = arr[0] - arr[1]
	for i in range(n - 2):
		if arr[i] - arr[i + 1] != checksum:
			ok = False
			break
	return ok

def main():
	global n, a
	n = int(input())
	b = [int(i) for i in input().split()]
	a = sorted(b)
	maxi = -10000000000.0
	for i in range(1, n):
		maxi = max(maxi, a[i] - a[i - 1])
	if ans(0):
		print(b.index(a[0]) + 1)
		return 0
	if ans(n - 1):
		print(b.index(a[n - 1]) + 1)
		return 0
	flag = 0
	for i in range(1, n):
		if a[i] - a[i - 1] != maxi:
			flag += 1
			if ans(i):
				print(b.index(a[i]) + 1)
				return 0
			if ans(i - 1):
				print(b.index(a[i - 1]) + 1)
				return 0
			if flag > 2:
				break
	print(-1)
a = []
n = 0
main()


a = int(input())
m = list(map(int, input().split()))
m1 = list(m)
m1.sort()
d = dict()
answ = 'f'
s = set()
m2 = dict()
c = 0
for i in range(1, a):
	if m1[i] - m1[i - 1] not in s:
		d[m1[i] - m1[i - 1]] = 1
		s.add(m1[i] - m1[i - 1])
	else:
		d[m1[i] - m1[i - 1]] += 1
for i in range(a):
	f = False
	h = False
	if i == 0:
		d[m1[1] - m1[0]] -= 1
		if d[m1[1] - m1[0]] == 0:
			c -= 1
		if len(d.keys()) + c == 1 or len(d.keys()) + c == 0:
			answ = m.index(m1[i]) + 1
		else:
			if d[m1[1] - m1[0]] == 0:
				c += 1
			d[m1[1] - m1[0]] += 1
	elif i == a - 1:
		d[m1[-1] - m1[-2]] -= 1
		if d[m1[-1] - m1[-2]] == 0:
			c -= 1
		if len(d.keys()) + c == 1 or len(d.keys()) + c == 0:
			answ = m.index(m1[i]) + 1
		else:
			if d[m1[-1] - m1[-2]] == 0:
				c += 1
			d[m1[-1] - m1[-2]] += 1
	else:
		d[m1[i] - m1[i - 1]] -= 1
		if d[m1[i] - m1[i - 1]] == 0:
			h = True
			m2[m1[i] - m1[i - 1]] = True
			c -= 1
		d[m1[i + 1] - m1[i]] -= 1
		if d[m1[i + 1] - m1[i]] == 0:
			f = True
			m2[m1[i + 1] - m1[i]] = True
			c -= 1
		if m1[i + 1] - m1[i - 1] not in s:
			d[m1[i + 1] - m1[i - 1]] = 1
			s.add(m1[i + 1] - m1[i - 1])
		else:
			d[m1[i + 1] - m1[i - 1]] += 1
			if d[m1[i + 1] - m1[i - 1]] == 1 and m2.get(m1[i + 1] - m1[i - 1], False):
				c += 1
		if len(d.keys()) + c == 1 or len(d.keys()) + c == 0:
			answ = m.index(m1[i]) + 1
		else:
			d[m1[i] - m1[i - 1]] += 1
			d[m1[i + 1] - m1[i]] += 1
			d[m1[i + 1] - m1[i - 1]] -= 1
			if d[m1[i + 1] - m1[i - 1]] == 0:
				c -= 1
				m2[m1[i + 1] - m1[i - 1]] = True
			if f:
				c += 1
			if h:
				c += 1
	if answ != 'f':
		break
if answ == 'f':
	answ = -1
print(answ)


def check(u, p=None):
	d = u[1] - u[0]
	if p == None:
		p = len(u)
	for i in range(p - 1):
		if u[i + 1] - u[i] != d:
			return False
	return True
n = int(input())
array = list(map(int, input().split()))
l = array[:]
l.sort()
if n <= 3:
	print(1)
elif check(l, n) or check(l[1:], n - 1):
	print(array.index(l[0]) + 1)
elif check([l[0]] + l[2:], n - 1):
	print(array.index(l[1]) + 1)
else:
	i = None
	d = l[1] - l[0]
	for k in range(n - 1):
		if l[k + 1] - l[k] != d:
			i = k + 1
			break
	if check(l[:i] + l[i + 1:]):
		print(array.index(l[i]) + 1)
	else:
		print(-1)


n = int(input())
B = [int(x) for x in input().split()]
A = sorted(B)
Diff = []
for i in range(n - 1):
	Diff.append(A[i + 1] - A[i])
if n == 2:
	print(1)
else:
	ANSWER = 'hehe'
	firstworks = True
	for i in range(1, n - 2):
		if Diff[i] != Diff[i + 1]:
			firstworks = False
	if firstworks:
		ANSWER = A[0]
	else:
		secondworks = True
		if A[2] - A[0] == Diff[2]:
			for i in range(n - 4):
				if Diff[i + 2] != Diff[i + 3]:
					secondworks = False
		else:
			secondworks = False
		if secondworks:
			ANSWER = A[1]
		else:
			dif = A[1] - A[0]
			T = []
			for i in range(n - 1):
				if Diff[i] != dif:
					T.append((Diff[i], i))
			if len(T) >= 3:
				ANSWER = 'hehe'
			elif len(T) == 2:
				if T[1][1] - T[0][1] == 1 and T[1][0] + T[0][0] == dif:
					ANSWER = A[T[0][1] + 1]
				else:
					ANSWER = 'hehe'
			elif len(T) == 1:
				if T[0][1] == n - 2:
					ANSWER = A[n - 1]
				else:
					ANSWER = 'hehe'
			else:
				ANSWER = A[n - 1]
	if ANSWER == 'hehe':
		print(-1)
	else:
		for i in range(n):
			if B[i] == ANSWER:
				print(i + 1)
				break


n = int(input())
r = list(map(int, input().split()))
l = [[r[i], i] for i in range(n)]
l.sort()
if n < 4:
	print(1)
else:
	nie = 0
	chuj = -1
	sk = 0
	wyn = 0
	gap = l[1][0] - l[0][0]
	for i in range(1, n):
		if nie == 0:
			if l[i][0] != l[i - 1][0] + gap:
				chuj = i
				nie += 1
				sk = 1
		elif i == chuj + 1:
			if l[i][0] != l[i - 2][0] + gap:
				nie += 1
				break
		elif l[i][0] != l[i - 1][0] + gap:
			nie += 1
			break
	if nie == 0:
		print(l[0][1] + 1)
	if nie == 1:
		print(l[chuj][1] + 1)
	if nie > 1:
		nie = 0
		chuj = -1
		sk = 0
		wyn = 0
		l.reverse()
		gap = l[1][0] - l[0][0]
		for i in range(1, n):
			if nie == 0:
				if l[i][0] != l[i - 1][0] + gap:
					chuj = i
					nie += 1
					sk = 1
			elif i == chuj + 1:
				if l[i][0] != l[i - 2][0] + gap:
					nie += 1
					break
			elif l[i][0] != l[i - 1][0] + gap:
				nie += 1
				break
		if nie == 0:
			print(l[0][1] + 1)
		if nie == 1:
			print(l[chuj][1] + 1)
		if nie > 1:
			print(-1)


import os
import sys
from io import BytesIO, IOBase
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')

class union_find:

	def __init__(self, n):
		self.n = n
		self.rank = [0] * n
		self.parent = [int(j) for j in range(n)]

	def union(self, i, j):
		i = self.find(i)
		j = self.find(j)
		if self.rank[i] == self.rank[j]:
			self.parent[i] = j
			self.rank[j] += 1
		elif self.rank[i] > self.rank[j]:
			self.parent[j] = i
		else:
			self.parent[i] = j

	def find(self, i):
		temp = i
		if self.parent[temp] != temp:
			self.parent[temp] = self.find(self.parent[temp])
		return self.parent[temp]
from math import log2, ceil
from collections import deque, Counter as CC, defaultdict as dd
MOD = int(1000000000.0 + 7)

def main():
	n = int(input())
	l = [(int(j), ct) for (ct, j) in enumerate(input().split())]
	l.sort()
	m = []
	for i in range(n - 1):
		m.append(l[i + 1][0] - l[i][0])
	if len(set(m[1:])) <= 1:
		print(l[0][1] + 1)
	elif len(set(m[:-1])) <= 1:
		print(l[n - 1][1] + 1)
	else:
		tmp = max(m)
		ct = 0
		flag = True
		ans_f = True
		ans = -1
		i = 0
		while i < n - 1:
			if m[i] != tmp and flag:
				if i + 1 < n - 1:
					tmp1 = m[i] + m[i + 1]
					if tmp == tmp1:
						flag = False
						ans = i + 1
						i += 1
					else:
						ans_f = False
						break
				else:
					ans_f = False
					break
			elif m[i] != tmp and (not flag):
				ans_f = False
				break
			i += 1
		if ans_f:
			print(l[ans][1] + 1)
		else:
			print(-1)
main()


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()


def f(x):
	return x[0]
n = int(input())
li = list(map(int, input().split()))
if len(li) == 2:
	print(1)
else:
	l = []
	for i in range(n):
		l.append([li[i], i + 1])
	l.sort(key=f)
	d = l[2][0] - l[1][0]
	flag = True
	for i in range(3, n):
		if l[i][0] - l[i - 1][0] != d:
			flag = False
			break
	if flag:
		print(l[0][1])
	else:
		d = l[1][0] - l[0][0]
		flag = True
		for i in range(2, n - 1):
			if l[i][0] - l[i - 1][0] != d:
				flag = False
				break
		if flag:
			print(l[n - 1][1])
		else:
			di = {}
			for i in range(1, n):
				if l[i][0] - l[i - 1][0] in di:
					di[l[i][0] - l[i - 1][0]] += 1
				else:
					di[l[i][0] - l[i - 1][0]] = 1
			j = list(di.keys())
			j.sort()
			if len(j) == 2 and (di[j[0]] == 2 and 2 * j[0] == j[1] or (j[0] == 0 and di[j[0]] == 1)):
				for i in range(1, n):
					if l[i][0] - l[i - 1][0] == j[0]:
						print(l[i][1])
						break
			elif len(j) == 3 and j[0] + j[1] == j[2] and (di[j[0]] == 1) and (di[j[1]] == 1):
				for i in range(1, n):
					if l[i][0] - l[i - 1][0] == j[0] or l[i][0] - l[i - 1][0] == j[1]:
						print(l[i][1])
						break
			else:
				print(-1)


n = int(input())
if n == 2 or n == 3:
	print(1)
	exit(0)
L = [int(x) for x in input().split()]
l = sorted(L)
arr = []
temp = l[1:]
for i in range(1, len(temp)):
	arr.append(temp[i] - temp[i - 1])
if arr.count(arr[0]) == len(arr):
	print(L.index(l[0]) + 1)
	exit(0)
arr = []
temp = l[:n - 1]
for i in range(1, len(temp)):
	arr.append(temp[i] - temp[i - 1])
if arr.count(arr[0]) == len(arr):
	print(L.index(l[n - 1]) + 1)
	exit(0)
arr = []
for i in range(1, n):
	arr.append(l[i] - l[i - 1])
if arr.count(arr[0]) == len(arr):
	print(1)
	exit(0)
temp = sorted(arr)
if temp[2] == temp[-1]:
	index = min(arr.index(temp[0]) + 1, arr.index(temp[1]) + 1)
	ans = L.index(l[index]) + 1
	l.remove(l[index])
	arr = []
	for i in range(1, len(l)):
		arr.append(l[i] - l[i - 1])
	if arr.count(arr[0]) == len(arr):
		print(ans)
	else:
		print(-1)
else:
	print(-1)


import operator
import sys
n = int(input())
l1 = list(map(int, input().split()))
l4 = l1.copy()
l3 = []
for i in range(n):
	l3.append((l1[i], i))
l3.sort()
l1.sort()
d1 = {}
l2 = []
for i in range(1, n):
	x = l1[i] - l1[i - 1]
	l2.append(x)
	if x in d1:
		d1[x] += 1
	else:
		d1[x] = 1
if n < 4:
	print(1)
elif n < 10:
	for i in range(n):
		l2 = []
		for j in range(n):
			if i != j:
				l2.append(l4[j])
		l2.sort()
		flag = 0
		x = l2[1] - l2[0]
		for j in range(1, n - 1):
			if l2[j] - l2[j - 1] != x:
				flag = 1
		if flag == 0:
			print(i + 1)
			sys.exit()
	print(-1)
elif len(d1) > 3:
	print(-1)
else:
	k = max(d1.items(), key=operator.itemgetter(1))[0]
	for j in range(len(l2)):
		if l2[j] != k:
			if j == 0:
				if l2.count(k) == len(l2) - 1:
					print(l3[0][1] + 1)
					sys.exit()
				else:
					if l2[j] + l2[j + 1] == k:
						if l2.count(k) == len(l2) - 2:
							print(l3[j + 1][1] + 1)
							sys.exit()
					print(-1)
					sys.exit()
			elif j == len(l2) - 1:
				print(l3[-1][1] + 1)
				sys.exit()
			elif l2[j] + l2[j + 1] == k:
				print(l3[j + 1][1] + 1)
				sys.exit()
			else:
				print(-1)
				sys.exit()
	print(l3[-1][1] + 1)


n = int(input())
arr = list(map(int, input().split()))
if n < 4:
	print(1)
	exit()
for i in range(n):
	arr[i] = (arr[i], i)
arr.sort()

def check(arr_temp):
	(d1, d2) = (-1, -1)
	(cnt1, cnt2) = (0, 0)
	for i in range(1, n - 1):
		if arr_temp[i][0] - arr_temp[i - 1][0] == d1 or d1 == -1:
			d1 = arr_temp[i][0] - arr_temp[i - 1][0]
			cnt1 += 1
		elif arr_temp[i][0] - arr_temp[i - 1][0] == d2 or d2 == -1:
			d2 = arr_temp[i][0] - arr_temp[i - 1][0]
			cnt2 += 1
	return cnt1 == n - 2 and cnt2 == 0 or (cnt1 == 0 and cnt2 == n - 2)

def solve(idx1, idx2, idx3):
	if check(arr[:idx1] + arr[idx1 + 1:]):
		print(arr[idx1][1] + 1)
	elif check(arr[:idx2] + arr[idx2 + 1:]):
		print(arr[idx2][1] + 1)
	elif check(arr[:idx3] + arr[idx3 + 1:]):
		print(arr[idx3][1] + 1)
	elif check(arr[:idx1 - 1] + arr[idx1:]):
		print(arr[idx1 - 1][1] + 1)
	elif check(arr[:idx2 - 1] + arr[idx2:]):
		print(arr[idx2 - 1][1] + 1)
	elif check(arr[:idx3 - 1] + arr[idx3:]):
		print(arr[idx3 - 1][1] + 1)
	else:
		print(-1)
	exit()
(d1, d2, d3) = (-1, -1, -1)
(idx1, idx2, idx3) = (-1, -1, -1)
for i in range(1, n):
	if arr[i][0] - arr[i - 1][0] == d1 or d1 == -1:
		d1 = arr[i][0] - arr[i - 1][0]
		idx1 = i
	elif arr[i][0] - arr[i - 1][0] == d2 or d2 == -1:
		d2 = arr[i][0] - arr[i - 1][0]
		idx2 = i
	elif arr[i][0] - arr[i - 1][0] == d3 or d3 == -1:
		d3 = arr[i][0] - arr[i - 1][0]
		idx3 = i
solve(idx1, idx2, idx3)


from operator import itemgetter
import sys
input = sys.stdin.readline

def main():
	N = int(input())
	B = list(map(int, input().split()))
	A = []
	for (i, b) in enumerate(B):
		A.append((i + 1, b))
	A.sort(key=itemgetter(1))
	(a0, a1) = (A[0][1], A[1][1])
	A1 = [a0 + (a1 - a0) * j for j in range(N - 1)]
	dif = []
	i = 0
	j = 0
	ok = True
	while i < N and j < N - 1:
		if A[i][1] == A1[j]:
			i += 1
			j += 1
		elif i < N - 1:
			if A[i + 1][1] == A1[j]:
				dif.append(A[i][0])
				i += 1
			else:
				ok = False
				break
		else:
			ok = False
			break
		if i != j and i != j + 1:
			ok = False
			break
	if ok:
		if len(dif) == 1:
			print(dif[0])
			return
		elif len(dif) == 0:
			print(A[N - 1][0])
			return
	(a1, a2) = (A[1][1], A[2][1])
	A2 = [a1 + (a2 - a1) * (j - 1) for j in range(N)]
	ok = True
	for i in range(1, N):
		if A[i][1] != A2[i]:
			ok = False
			break
	if ok:
		print(A[0][0])
		return
	ok = True
	d = a2 - a0
	A3 = [a0 + d * j for j in range(N - 1)]
	for j in range(1, N - 1):
		if A[j + 1][1] != A3[j]:
			ok = False
			break
	if ok:
		print(A[1][0])
		return
	print(-1)
main()


from copy import *
n = int(input())
l = list(map(int, input().split()))
for i in range(n):
	l[i] = [l[i], i + 1]
l.sort()
mask = deepcopy(l)
dif = l[1][0] - l[0][0]
ok = 2
ind = l[n - 1][1]
for i in range(1, n):
	if mask[i][0] - mask[i - 1][0] != dif:
		ok -= 1
		ind = mask[i][1]
		mask[i][0] = mask[i - 1][0]
if ok >= 1:
	print(ind)
	exit()
ok = 1
mask = deepcopy(l)
dif = l[2][0] - l[1][0]
for i in range(2, n):
	if mask[i][0] - mask[i - 1][0] != dif:
		ok -= 1
if ok == 1:
	print(l[0][1])
	exit()
ok = 1
mask = deepcopy(l)
dif = l[2][0] - l[0][0]
for i in range(3, n):
	if mask[i][0] - mask[i - 1][0] != dif:
		ok -= 1
if ok == 1:
	print(l[1][1])
	exit()
print(-1)


def getN():
	return int(input())

def getList():
	return list(map(int, input().split()))
import sys
from copy import deepcopy
n = getN()
nums = getList()
org = deepcopy(nums)
nums.sort()
diff = [b - a for (a, b) in zip(nums, nums[1:])]
if len(list(set(diff[1:]))) == 1:
	print(org.index(nums[0]) + 1)
	sys.exit(0)
if len(list(set(diff[:-1]))) == 1:
	print(org.index(nums[-1]) + 1)
	sys.exit(0)
kind = list(set(diff))
kind.sort()
if len(kind) > 3:
	print(-1)
	sys.exit(0)
if len(kind) == 1:
	print(1)
	sys.exit(0)
if len(kind) == 2:
	if kind[0] == 0:
		gap = []
		for (i, di) in enumerate(diff):
			if di == 0:
				gap.append(i)
		if len(gap) != 1:
			print(-1)
			sys.exit(0)
		tgt_num = nums[gap[0]]
		print(org.index(tgt_num) + 1)
		sys.exit()
	if kind[1] != kind[0] * 2:
		print(-1)
		sys.exit()
	gap = []
	for (i, di) in enumerate(diff):
		if di == kind[0]:
			gap.append(i)
	if len(gap) != 2 or gap[0] + 1 != gap[1]:
		print(-1)
		sys.exit(0)
if len(kind) == 3:
	if kind[0] + kind[1] != kind[2]:
		print(-1)
		sys.exit()
	gap = []
	for (i, di) in enumerate(diff):
		if di == kind[0] or di == kind[1]:
			gap.append(i)
	if len(gap) != 2 or gap[0] + 1 != gap[1]:
		print(-1)
		sys.exit(0)
tgt_num = nums[gap[1]]
print(org.index(tgt_num) + 1)


import sys
n = int(sys.stdin.readline().strip())
b = list(map(int, sys.stdin.readline().strip().split()))
c = sorted(b)
if n == 2 or n == 3:
	print(1)
else:
	d = c[1] - c[0]
	v = False
	x = c[-1]
	ans = True
	for i in range(0, n - 1):
		if v == False and c[i] != c[0] + i * d:
			v = True
			x = c[i]
		if v == True and c[i + 1] != c[0] + i * d:
			ans = False
	if ans == True:
		print(b.index(x) + 1)
	else:
		d = c[-1] - c[-2]
		v = False
		x = c[0]
		ans = True
		for i in range(0, n - 1):
			if v == False and c[n - 1 - i] != c[n - 1] - i * d:
				v = True
				x = c[n - 1 - i]
			if v == True and c[n - 2 - i] != c[n - 1] - i * d:
				ans = False
		if ans == True:
			print(b.index(x) + 1)
		else:
			print(-1)


import math
import heapq
import copy
from collections import OrderedDict
from collections import deque
t = int(input())
k = list(map(int, input().split()))
m = list(k)
m.sort()
start = m[0]
end = m[t - 1]
if t == 2 or t == 3:
	print(1)
else:
	val1 = []
	val2 = []
	val3 = []
	for i in range(0, t - 1):
		d = m[i + 1] - m[i]
		val1.append(d)
	for i in range(1, t - 1):
		d = m[i + 1] - m[i]
		val2.append(d)
	for i in range(0, t - 2):
		d = m[i + 1] - m[i]
		val3.append(d)
	if len(set(val2)) == 1 or len(set(val1)) == 1:
		print(k.index(m[0]) + 1)
		exit(0)
	if len(set(val3)) == 1:
		print(k.index(m[t - 1]) + 1)
		exit(0)
	if len(set(val2)) > 1:
		p = min(val2)
		q = max(val2)
		if m[0] + p * (t - 2) == m[t - 1]:
			count = 0
			index = 0
			j = 0
			for i in range(1, t + 1):
				if m[0] + p * (i - j - 1) != m[i - 1]:
					count = count + 1
					index = i - 1
					j = j + 1
			if count > 1:
				print(-1)
				exit(0)
			else:
				print(k.index(m[index]) + 1)
				exit(0)
		elif m[0] + q * (t - 2) == m[t - 1]:
			count = 0
			index = 0
			j = 0
			for i in range(1, t + 1):
				if m[0] + q * (i - j - 1) != m[i - 1]:
					count = count + 1
					j = j + 1
					index = i - 1
			if count > 1:
				print(-1)
				exit(0)
			else:
				print(k.index(m[index]) + 1)
				exit(0)
		else:
			print(-1)
			exit(0)
	print(-1)


n = int(input())
lst = list(map(int, input().split()))
di = {}
for (i, x) in enumerate(lst):
	if di.get(x) == None:
		di[x] = i + 1
lst.sort()
d = {}
for i in range(1, n):
	x = lst[i] - lst[i - 1]
	if d.get(x) == None:
		d[x] = 0
	d[x] += 1
key = list(d.keys())
length = len(key)
res = ''
from sys import exit
if length > 3:
	res = 'NO'
else:
	key.sort()
	if length == 3:
		if d[key[0]] == 1 and d[key[1]] == 1:
			if key[0] + key[1] == key[2]:
				res = 'YES'
			else:
				res = 'NO'
		else:
			res = 'NO'
	elif length == 2:
		if lst[1] - lst[0] == key[0] and d[key[0]] == 1:
			print(di[lst[0]])
			exit()
		if lst[1] - lst[0] == key[1] and d[key[1]] == 1:
			print(di[lst[0]])
			exit()
		if lst[n - 1] - lst[n - 2] == key[0] and d[key[0]] == 1:
			print(di[lst[n - 1]])
			exit()
		if lst[n - 1] - lst[n - 2] == key[1] and d[key[1]] == 1:
			print(di[lst[n - 1]])
			exit()
		if d[key[0]] == 2:
			if key[0] * 2 == key[1]:
				res = 'YES'
			else:
				res = 'NO'
		elif d[key[0]] == 1 and key[0] == 0:
			res = 'YES'
		else:
			res = 'NO'
	else:
		print(di[lst[0]])
		exit()
if res == 'NO':
	print(-1)
else:
	for i in range(1, n - 1):
		if lst[i + 1] - lst[i - 1] == key[len(key) - 1]:
			print(di[lst[i]])
			exit()


import math
import bisect
import heapq
from collections import defaultdict

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, x, y) = egcd(b % a, a)
		return (g, y - b // a * x, x)

def mulinv(b, n):
	(g, x, _) = egcd(b, n)
	if g == 1:
		return x % n

def isprime(n):
	for d in range(2, int(math.sqrt(n)) + 1):
		if n % d == 0:
			return False
	return True

def argsort(ls):
	return sorted(range(len(ls)), key=ls.__getitem__)

def f(p=0):
	if p == 1:
		return map(int, input().split())
	elif p == 2:
		return list(map(int, input().split()))
	elif p == 3:
		return list(input())
	else:
		return int(input())

class DisjointSet:

	def __init__(self, n):
		self.parent = [i for i in range(1, n + 1)]
		self.rank = [0] * (n + 1)

	def find_set(self, x):
		if self.parent[x] == x:
			return x
		else:
			self.parent[x] = self.find_set(self.parent[x])
			return self.parent[x]

	def union(self, x, y):
		set_x = self.find_set(x)
		set_y = self.find_set(y)
		if set_x != set_y:
			if self.rank[x]:
				pass

def graph(n, m, edg=False):
	edges = []
	visited = [0] * n
	g = [list() for _ in range(n + 1)]
	for i in range(m):
		(u, v) = f(1)
		g[u].append(v)
		g[v].append(u)
		if edg:
			edges.append((u, v))
	if edg:
		return (g, visited, edg)
	else:
		return (g, visited)

def bfs(g, visited):
	queue = [1]
	visited[1] = 1
	for u in queue:
		for v in g[u]:
			if visited[v] == 0:
				queue.append(v)
			visited[v] = 1

def dfs(u, g, visited):
	visited[u] = 1
	for v in g[u]:
		if visited[v] == 0:
			dfs(v, g, visited)
n = f()
scl = f(2)
cl = sorted(scl)
if n < 4:
	print(1)
else:
	a = cl[-1] - cl[1]
	d = int(a / (n - 2))
	if d == a / (n - 2):
		st = True
		for i in range(1, n - 1):
			if cl[i + 1] - cl[i] != d:
				st = False
				break
		if st:
			mn = cl[0]
			for i in range(n):
				if scl[i] == mn:
					print(i + 1)
					exit()
	a = cl[n - 2] - cl[0]
	d = int(a / (n - 2))
	if d == a / (n - 2):
		st = True
		for i in range(n - 2):
			if cl[i + 1] - cl[i] != d:
				st = False
				break
		if st:
			mn = cl[-1]
			for i in range(n):
				if scl[i] == mn:
					print(i + 1)
					exit()
	a = cl[-1] - cl[0]
	d = int(a / (n - 2))
	pos = -10 ** 10
	if d == a / (n - 2):
		st = True
		i = 0
		while i < n - 1:
			if cl[i + 1] - cl[i] != d:
				if not st:
					print(-1)
					exit()
				elif i == n - 2 or cl[i + 2] - cl[i] == d:
					st = False
					pos = cl[i + 1]
					i += 1
				else:
					print(-1)
					exit()
			i += 1
		if pos != -10 ** 10:
			for i in range(n):
				if scl[i] == pos:
					print(i + 1)
					exit()
	print(-1)
	exit()


n = int(input())
if n == 1 or n == 2:
	print(1)
	exit()
q = []
c = 0
for i in map(int, input().split()):
	q.append([i, c])
	c += 1
q.sort()
w = {}
for i in range(1, n):
	g = q[i][0] - q[i - 1][0]
	if g not in w:
		w[g] = 1
	else:
		w[g] += 1
if len(w) > 3:
	print(-1)
	exit()
boo = 1
for i in range(n):
	er = dict(w)
	c = 0
	if i != 0:
		er[q[i][0] - q[i - 1][0]] -= 1
		if er[q[i][0] - q[i - 1][0]] == 0:
			del er[q[i][0] - q[i - 1][0]]
		c += q[i][0] - q[i - 1][0]
	if i != n - 1:
		er[q[i + 1][0] - q[i][0]] -= 1
		if er[q[i + 1][0] - q[i][0]] == 0:
			del er[q[i + 1][0] - q[i][0]]
		c += q[i + 1][0] - q[i][0]
	if i == 0 and len(er) == 1:
		print(q[i][1] + 1)
		exit()
	if i == n - 1 and len(er) == 1:
		print(q[i][1] + 1)
		exit()
	if len(er) != 1:
		continue
	if c not in er:
		pass
	else:
		print(q[i][1] + 1)
		exit()
print(-1)


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)


def popped_index(case):
	if not case:
		return -1
	valid = True
	invalid_index = 0
	left = sorted(case.copy())
	popped = left[0]
	for i in range(len(left) - 2):
		if left[i + 2] - left[i + 1] != left[i + 1] - left[i]:
			invalid_index = i + 2
			break
	if invalid_index != 0:
		popped = left.pop(invalid_index)
	for i in range(len(left) - 2):
		if left[i + 2] - left[i + 1] != left[i + 1] - left[i]:
			valid = False
			break
	if valid:
		return case.index(popped) + 1
	valid = True
	invalid_index = len(case) - 1
	right = sorted(case.copy())
	popped = right[len(case) - 1]
	for i in range(len(right) - 1, 1, -1):
		if right[i] - right[i - 1] != right[i - 1] - right[i - 2]:
			invalid_index = i - 2
			break
	if invalid_index != len(case) - 1:
		popped = right.pop(invalid_index)
	for i in range(len(right) - 1, 1, -1):
		if right[i] - right[i - 1] != right[i - 1] - right[i - 2]:
			valid = False
			break
	if valid:
		return case.index(popped) + 1
	else:
		return -1
_ = input()
case = list(map(int, input().strip().split(' ')))
print(popped_index(case))


n = int(input())
arr1 = list(map(int, input().split()))
arr = []
for i in range(n):
	arr.append((arr1[i], i + 1))
arr.sort()
if n <= 3:
	print(1)
else:
	diff = arr[2][0] - arr[1][0]
	flag = 0
	for i in range(2, n):
		if arr[i][0] - arr[i - 1][0] != diff:
			flag = 1
			break
	if flag == 0:
		print(arr[0][1])
	else:
		flag = 0
		diff = arr[2][0] - arr[0][0]
		for i in range(3, n):
			if arr[i][0] - arr[i - 1][0] != diff:
				flag = 1
				break
		if flag == 0:
			print(arr[1][1])
		else:
			diff = arr[1][0] - arr[0][0]
			indexes = []
			if diff == 0:
				count = 0
				for i in range(n):
					if arr[i][0] == arr[0][0]:
						count += 1
					else:
						indexes.append(arr[i][1])
				if count == n - 1:
					print(indexes[0])
				else:
					print(-1)
			else:
				mark = [0] * n
				for i in range(n):
					if (arr[i][0] - arr[0][0]) % diff == 0:
						if (arr[i][0] - arr[0][0]) // diff <= n - 1 and mark[(arr[i][0] - arr[0][0]) // diff] == 0:
							mark[(arr[i][0] - arr[0][0]) // diff] = 1
						else:
							indexes.append(arr[i][1])
					else:
						indexes.append(arr[i][1])
				if len(indexes) > 1:
					print(-1)
				else:
					flag = 0
					for i in range(n - 1):
						if mark[i] == 0:
							flag = 1
							break
					if flag == 1:
						print(-1)
					else:
						print(indexes[0])


n = int(input())
a = list(map(int, input().split()))
res = -1
a = list(map(lambda x: (x[1], x[0]), enumerate(a)))
a.sort()
cnt = 0
if n == 2:
	res = 1
else:
	diff = a[1][0] - a[0][0]
	cnt = 0
	prev = a[0][0]
	ind = 0
	for i in range(1, len(a)):
		if a[i][0] - prev == diff:
			prev = a[i][0]
		else:
			cnt += 1
			ind = a[i][1]
	if cnt > 1:
		if n == 2:
			ind = 0
		else:
			diff = a[2][0] - a[1][0]
			prev = a[1][0]
			ind = 0
			cnt = 0
			for i in range(2, len(a)):
				if a[i][0] - prev == diff:
					prev = a[i][0]
				else:
					cnt += 1
			if cnt != 0:
				diff = a[2][0] - a[0][0]
				cnt = 0
				prev = a[0][0]
				for i in range(2, len(a)):
					if a[i][0] - prev == diff:
						prev = a[i][0]
					else:
						cnt += 1
				if cnt != 0:
					ind = -2
					cnt += 1
				else:
					ind = a[1][1]
			else:
				ind = a[0][1]
	elif cnt == 0:
		ind = a[0][1]
	res = ind
if cnt > 1:
	res = -2
print(res + 1)


import math
from decimal import Decimal

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
(n, a) = na()
s = []
if n == 2 or n == 3:
	print(1)
	exit()
for i in range(n):
	a[i] = (a[i], i + 1)
a.sort()
for i in range(n - 1):
	rz = a[i + 1][0] - a[i][0]
	s.append(rz)
if len(set(s[1:])) == 1:
	print(a[0][1])
	exit()
if len(set(s[:-1])) == 1:
	print(a[-1][1])
	exit()
d = {}
for i in s:
	if i not in d:
		d[i] = 0
	d[i] += 1
for i in d:
	if d[i] >= n - 3:
		b = []
		for j in range(n - 1):
			if s[j] != i:
				b.append((s[j], j))
		if len(b) == 1:
			if b[0][0] == 0:
				print(a[b[0][1]][1])
				exit()
		if len(b) == 2:
			(c, k) = (b[0], b[1])
			if c[0] + k[0] == i:
				if abs(c[1] - k[1]) == 1:
					print(a[c[1] + 1][1])
					exit()
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)


import sys, math, queue, bisect
MOD = 10 ** 9 + 7
sys.setrecursionlimit(1000000)
n = int(input())
a = list(map(int, input().split()))
if n <= 3:
	print(1)
	exit()
a = [(a[i], i + 1) for i in range(n)]
a.sort()
d = {}
for i in range(1, n):
	dd = a[i][0] - a[i - 1][0]
	if dd in d:
		d[dd] += 1
	else:
		d[dd] = 1
dd = a[1][0] - a[0][0]
d[dd] -= 1
if d[dd] == 0:
	del d[dd]
if len(d) == 1:
	print(a[0][1])
	exit()
if dd not in d:
	d[dd] = 1
else:
	d[dd] += 1
dd = a[-1][0] - a[-2][0]
d[dd] -= 1
if d[dd] == 0:
	del d[dd]
if len(d) == 1:
	print(a[-1][1])
	exit()
if dd not in d:
	d[dd] = 1
else:
	d[dd] += 1
for i in range(1, n - 1):
	dd1 = a[i][0] - a[i - 1][0]
	d[dd1] -= 1
	if d[dd1] == 0:
		del d[dd1]
	dd2 = a[i + 1][0] - a[i][0]
	d[dd2] -= 1
	if d[dd2] == 0:
		del d[dd2]
	if dd2 + dd1 in d:
		d[dd1 + dd2] += 1
	else:
		d[dd1 + dd2] = 1
	if len(d) == 1:
		print(a[i][1])
		exit()
	if dd1 not in d:
		d[dd1] = 1
	else:
		d[dd1] += 1
	if dd2 not in d:
		d[dd2] = 1
	else:
		d[dd2] += 1
	d[dd1 + dd2] -= 1
	if d[dd1 + dd2] == 0:
		del d[dd1 + dd2]
print(-1)


N = int(input())
arr = input()
arr = [int(x) for x in arr.split(' ')]
cp = list(arr)
arr.sort()
res = -1
tmp = arr[1:]
diff = {}
count = 0
for i in range(1, len(tmp)):
	d = tmp[i] - tmp[i - 1]
	if d not in diff:
		count += 1
		if count > 1:
			break
		diff[d] = 1
if count == 1 or len(arr) == 2:
	target = arr[0]
	for i in range(N):
		if cp[i] == target:
			print(i + 1)
			res = i + 1
			break
if res == -1:
	tmp = arr[:N - 1]
	diff = {}
	count = 0
	for i in range(1, len(tmp)):
		d = tmp[i] - tmp[i - 1]
		if d not in diff:
			count += 1
			if count > 1:
				break
			diff[d] = 1
	if count == 1:
		target = arr[-1]
		for i in range(N):
			if cp[i] == target:
				print(i + 1)
				res = i + 1
				break
if res == -1:
	head = arr[0]
	tail = arr[-1]
	if (tail - head) % (N - 2) != 0:
		print(-1)
	else:
		d = (tail - head) // (N - 2)
		s = arr[0]
		flag = 0
		target = 11111111111111
		for i in range(1, N):
			s += d
			if s != arr[i] and flag == 0:
				flag += 1
				target = arr[i]
				s -= d
			elif flag == 1 and s != arr[i]:
				flag += 1
				print(-1)
				break
		if flag == 1:
			for i in range(N):
				if cp[i] == target:
					print(i + 1)
					break


def check_progr(a, n):
	s = a[1] - a[0]
	for i in range(1, n - 1):
		if a[i + 1] - a[i] != s:
			return False
	return True
n = int(input())
a = list(map(int, input().split()))
b = a.copy()
a.sort()
if n == 2:
	print(1)
	exit()
if check_progr(a[1:], n - 1):
	print(b.index(a[0]) + 1)
elif check_progr([a[0]] + a[2:], n - 1):
	print(b.index(a[1]) + 1)
else:
	s = a[1] - a[0]
	ans = 'bad'
	for i in range(1, n - 1):
		if a[i + 1] - a[i] != s:
			ans = a[i + 1]
			del a[i + 1]
			break
	if ans != 'bad' and check_progr(a, n - 1):
		print(b.index(ans) + 1)
	else:
		print(-1)


n = int(input())
a = list(map(int, input().split()))
dic = {}
for i in range(n):
	dic[str(a[i])] = i + 1
a.sort()
done = False
if n == 2 or n == 3:
	print(1)
else:
	d = [a[2] - a[1], a[2] - a[0], a[1] - a[0]]
	for i in range(2):
		ans = []
		if not done:
			for j in range(2, n - 1):
				if a[j + 1] - a[j] != d[i]:
					ans.append(a[j + 1])
			if len(ans) == 0:
				done = True
				print(dic.get(str(a[i])))
	if not done:
		ans = []
		cur = a[0]
		for i in range(n - 1):
			if a[i + 1] - cur != d[2]:
				ans.append(a[i + 1])
			else:
				cur = a[i + 1]
		if len(ans) < 2:
			done = True
			print(1 if len(ans) == 0 else dic.get(str(ans[0])))
		else:
			print(-1)


n = int(input())
array = list(map(int, input().split()))
if n == 1:
	print(1)
	exit(0)
s = sum(array)
for i in range(n):
	array[i] = (array[i], i + 1)
array.sort()
count = 0
for i in range(1, n - 1):
	if array[i][0] - array[i - 1][0] != array[i + 1][0] - array[i][0]:
		new_array = array.copy()
		new_array.pop(i - 1)
		q = True
		for j in range(1, n - 2):
			if new_array[j][0] - new_array[j - 1][0] != new_array[j + 1][0] - new_array[j][0]:
				q = False
				break
		if q:
			print(array[i - 1][1])
			exit(0)
		new_array = array.copy()
		new_array.pop(i)
		q = True
		for j in range(1, n - 2):
			if new_array[j][0] - new_array[j - 1][0] != new_array[j + 1][0] - new_array[j][0]:
				q = False
				break
		if q:
			print(array[i][1])
			exit(0)
		new_array = array.copy()
		new_array.pop(i + 1)
		q = True
		for j in range(1, n - 2):
			if new_array[j][0] - new_array[j - 1][0] != new_array[j + 1][0] - new_array[j][0]:
				q = False
				break
		if q:
			print(array[i + 1][1])
			exit(0)
		print(-1)
		exit(0)
print(array[0][1])


import os
import sys
from io import BytesIO, IOBase
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')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(RL())

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)

def toord(c):
	return ord(c) - ord('a')

def lcm(a, b):
	return a * b // gcd(a, b)
mod = 998244353
INF = float('inf')
from math import factorial, sqrt, ceil, floor, gcd
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	n = N()
	arr = RLL()
	rec = {}
	for i in range(n):
		rec[arr[i]] = i + 1
	st_arr = sorted(arr)
	if len(st_arr) <= 3:
		print(1)
		sys.exit()
	rm_fir = [st_arr[i] - st_arr[i - 1] for i in range(2, n)]
	if len(set(rm_fir)) == 1:
		print(rec[st_arr[0]])
		sys.exit()
	rm_lst = [st_arr[i] - st_arr[i - 1] for i in range(1, n - 1)]
	if len(set(rm_lst)) == 1:
		print(rec[st_arr[-1]])
		sys.exit()
	now = [st_arr[i] - st_arr[i - 1] for i in range(1, n)]
	ct = Counter(now)
	num = len(ct)

	def check(index):
		now_num = num
		pre = st_arr[index] - st_arr[index - 1]
		suf = st_arr[index + 1] - st_arr[index]
		new = st_arr[index + 1] - st_arr[index - 1]
		ct[pre] -= 1
		if ct[pre] == 0:
			now_num -= 1
		ct[suf] -= 1
		if ct[suf] == 0:
			now_num -= 1
		ct[new] += 1
		if ct[new] == 1:
			now_num += 1
		ct[new] -= 1
		ct[pre] += 1
		ct[suf] += 1
		if now_num == 1:
			return True
		return False
	for i in range(1, n - 1):
		if check(i):
			print(rec[st_arr[i]])
			break
	else:
		print(-1)
main()