There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. 

Find the way to distribute cards such that the sum of values written of the cards will be equal for each player. It is guaranteed that it is always possible.


-----Input-----

The first line of the input contains integer n (2 ≤ n ≤ 100) — the number of cards in the deck. It is guaranteed that n is even.

The second line contains the sequence of n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 100), where a_{i} is equal to the number written on the i-th card.


-----Output-----

Print n / 2 pairs of integers, the i-th pair denote the cards that should be given to the i-th player. Each card should be given to exactly one player. Cards are numbered in the order they appear in the input.

It is guaranteed that solution exists. If there are several correct answers, you are allowed to print any of them.


-----Examples-----
Input
6
1 5 7 4 4 3

Output
1 3
6 2
4 5

Input
4
10 10 10 10

Output
1 2
3 4



-----Note-----

In the first sample, cards are distributed in such a way that each player has the sum of numbers written on his cards equal to 8. 

In the second sample, all values a_{i} are equal. Thus, any distribution is acceptable.

Source: codeforces | Difficulty: EASY
Tags: Implementation

Greedy algorithms


Solutions:
n = int(input())
a = map(int, input().split())
b = sorted([[x, i + 1] for (i, x) in enumerate(a)])
for i in range(n // 2):
	print(b[i][1], b[n - i - 1][1])


a = int(input())
l = list(map(int, input().split()))
x = sum(l) // (a // 2)
g = []
for i in range(a):
	k = []
	if l[i] != 0:
		k.append(i + 1)
		t = l[i]
		l[i] = 0
		k.append(l.index(x - t) + 1)
		l[l.index(x - t)] = 0
		g.append(k)
for j in range(len(g)):
	print(g[j][0], g[j][1])


n = int(input())
xa = list(map(int, input().split()))
a = []
for i in range(len(xa)):
	a.append([xa[i], i + 1])
a.sort(key=lambda x: x[0])
for i in range(int(n // 2)):
	print(a[i][1], a[n - i - 1][1])


n = int(input())
arr = list(map(int, input().split()))
total = min(arr) + max(arr)
for i in range(len(arr)):
	for j in range(i, len(arr)):
		if total == arr[i] + arr[j] and i != j:
			print(i + 1, j + 1)
			arr[j] = 0
			break


__author__ = 'artyom'

def main():
	n = read()
	a = read(3)
	k = 2 * sum(a) // n
	b = [False] * n
	for i in range(n - 1):
		if not b[i]:
			for j in range(i + 1, n):
				if not b[j] and a[i] + a[j] == k:
					print(i + 1, j + 1)
					b[i] = b[j] = True
					break

def read(mode=1, size=None):
	if mode == 0:
		return input().strip()
	if mode == 1:
		return int(input().strip())
	if mode == 2:
		return input().strip().split()
	if mode == 3:
		return list(map(int, input().strip().split()))
	a = []
	for _ in range(size):
		a.append(read(3))
	return a
main()


n = int(input())
l = [int(i) for i in input().split()]
t = sum(l) * 2 // n
if n == 2:
	print(1, 2)
else:
	for i in range(n):
		if l[i] != 0:
			x = l[i]
			l[i] = 0
			m = l.index(t - x)
			print(i + 1, m + 1)
			l[m] = 0


n = int(input())
x = input().split()
for j in range(n):
	x[j] = int(x[j])
y = []
for i in range(n):
	y.append([x[i], i + 1])
y.sort()
for k in range(int(n / 2)):
	print(y[k][1], y[n - 1 - k][1])


n = int(input())
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in range(n)]
for i in range(n - 1):
	for j in range(i + 1, n):
		if a[i] >= a[j]:
			(a[i], a[j]) = (a[j], a[i])
			(b[i], b[j]) = (b[j], b[i])
for i in range(n // 2):
	print(b[i] + 1, b[n - i - 1] + 1)


n = int(input())
line = str(input())
line = line.split()
for i in range(n):
	line[i] = [int(line[i]), i + 1]
line.sort(key=lambda x: x[0])
for i in range(n // 2):
	print(str(line[i][1]) + ' ' + str(line[n - 1 - i][1]))


a = int(input())
s = [int(x) for x in input().split()]
s1 = sorted(s)
for i in range(a // 2):
	print(s.index(s1[i]) + 1, end=' ')
	s[s.index(s1[i])] = 0
	print(s.index(s1[a - i - 1]) + 1)
	s[s.index(s1[a - i - 1])] = 0


n = int(input())
temp = input().split()
c0 = [(int(temp[i]), i + 1) for i in range(len(temp))]
c0.sort()
for i in range(int(n / 2)):
	print('%d %d' % (c0[i][1], c0[n - i - 1][1]))


n = int(input())
t = list(map(int, input().rstrip().split()))
m = n / 2
sum = 0
for i in range(n):
	sum = sum + t[i]
avg = sum / m
for j in range(0, n):
	for k in range(j + 1, n):
		if t[j] + t[k] == avg:
			print(j + 1, end=' ')
			print(k + 1)
			t[j] = 0
			t[k] = 0
			break


x = int(input())
lst = list(map(int, input().split()))
ls1 = sorted(lst)
for i in range(len(lst) // 2):
	q1 = lst.index(ls1[i])
	lst[q1] = 'N'
	q2 = lst.index(ls1[-i - 1])
	lst[q2] = 'N'
	print(q1 + 1, q2 + 1)


n = int(input())
a = list(map(int, input().split()))
x = sum(a) * 2 // n
b = [False for i in range(n)]
for i in range(n):
	if not b[i]:
		for j in range(i + 1, n):
			if not b[j]:
				if a[i] + a[j] == x:
					print(i + 1, j + 1)
					b[i] = True
					b[j] = True
					break


n = int(input())
cards = [int(x) for x in input().split()]
new_l = []
for i in range(n):
	new_l.append((cards[i], i + 1))
lst = sorted(new_l, key=lambda x: x[0])
for i in range(n // 2):
	print(lst[i][1], lst[n - i - 1][1])


n = int(input())
cards = list(map(int, input().split()))
mount = sum(cards) * 2 // n
for i in range(n):
	curr = cards[i]
	if curr is None:
		continue
	cards[i] = None
	idx = cards.index(mount - curr)
	cards[idx] = None
	print(i + 1, idx + 1)


a = int(input())
b = list(map(int, input().split()))
c = []
for i in range(a):
	c.append([b[i], i])
c.sort()
for i in range(a // 2):
	print(str(c[i][1] + 1) + ' ' + str(c[a - 1 - i][1] + 1))


n = int(input())
ls = list(map(int, input().split()))
sl = ls.copy()
sl.sort()
j = n - 1
for i in range(int(n / 2)):
	if ls.index(sl[i]) != -1:
		print(ls.index(sl[i]) + 1, end=' ')
		ls[ls.index(sl[i])] = -1
	if ls.index(sl[j]) != -1:
		print(ls.index(sl[j]) + 1)
		ls[ls.index(sl[j])] = -1
	j = j - 1


def int_lst_input():
	return [int(val) for val in input().split(' ')]

def int_input():
	return int(input())

def solve():
	n = int_input()
	a = int_lst_input()
	target = sum(a) // (n // 2)
	idx_used = set()
	for i in range(0, n):
		for j in range(0, n):
			if i not in idx_used and j not in idx_used and (a[i] + a[j] == target) and (i != j):
				idx_used.add(i)
				idx_used.add(j)
				print(f'{i + 1} {j + 1}')
solve()


def main():
	n = int(input())
	x = list(map(int, input().split()))
	each_sum = sum(x) / (n // 2)
	for i in range(len(x)):
		for j in range(i + 1, len(x)):
			if x[i] + x[j] == each_sum and x[j] != 0:
				print(i + 1, j + 1)
				x[j] = 0
				break
main()


def main():
	n = int(input())
	cards = [0] + [int(_) for _ in input().split()]
	total_points = sum(cards)
	player_points = total_points // (n // 2)
	marked = [False] * (n + 1)
	count = 0
	for i in range(1, n):
		if marked[i]:
			continue
		for j in range(i + 1, n + 1):
			if not marked[j] and cards[i] + cards[j] == player_points:
				count += 1
				marked[i] = True
				marked[j] = True
				print(i, j)
				break
main()


n = int(input())
l = list(map(int, input().rstrip().split()))
l = sorted([[j, i + 1] for (i, j) in enumerate(l)])
for i in range(n // 2):
	print(l[i][1], l[-(i + 1)][1])


n = int(input())
cards = list(map(int, input().strip().split()))
maxSum = max(cards) + min(cards)
counter = 0
for i in range(0, n):
	if counter == int(n / 2):
		break
	for j in range(i + 1, n):
		if cards[i] + cards[j] == maxSum:
			print(i + 1, j + 1)
			counter += 1
			cards[i] = 0
			cards[j] = 0
		if counter == int(n / 2):
			break


read = lambda : list(map(int, input().split()))
n = int(input())
a = list(read())
a = [(a[i], i + 1) for i in range(n)]
a.sort()
for i in range(n // 2):
	print(a[i][1], a[n - i - 1][1])


n = int(input())
h = int(0)
x = int(0)
s = set()
t = 0
a = list(map(int, input().split()))

def acc(x):
	if x in s:
		return False
	else:
		return True
for i in range(len(a)):
	x += a[i]
x = x // (n // 2)
while h != n // 2:
	for i in range(len(a) - 1):
		for j in range(i + 1, len(a), 1):
			t = 0
			if a[i] + a[j] == x and acc(i) and acc(j):
				print(str(i + 1) + ' ' + str(j + 1))
				s.add(i)
				s.add(j)
				h += 1
				t = 1
				break
		if t == 1:
			break


from operator import itemgetter

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

def read_number():
	return int(input())
n = read_number()
a = read_number_line()
indices_values = enumerate(a, start=1)
indices_values = sorted(indices_values, key=itemgetter(1))
for i in range(n // 2):
	print(indices_values[i][0], indices_values[n - 1 - i][0])


n = int(input())
l = list(map(int, input().split()))
a = sum(l) // (n / 2)
l1 = []
for i in range(n):
	for j in range(i + 1, n):
		if l[i] + l[j] == a:
			if i + 1 not in l1 and j + 1 not in l1:
				l1.append(i + 1)
				l1.append(j + 1)
				break
for i in range(0, n - 1, 2):
	print(l1[i], l1[i + 1])


n = int(input())
l = list(map(int, input().split()))
a = max(l) + min(l)
d = 0
p = []
for i in range(n):
	if l[i] == 0:
		continue
	q = l[i]
	l[i] = 0
	c = l.index(a - q)
	l[c] = 0
	if i not in p and c not in p:
		p.append(i)
		p.append(c)
for i in range(1, len(p) + 1):
	if i % 2 != 0:
		print(p[i - 1] + 1, p[i] + 1)
		d += 1


n = int(input())
l = [[int(i), 0] for i in input().split()]
for i in range(n):
	l[i][1] = i + 1
l.sort()
for i in range(n // 2):
	print(l[i][1], l[n - i - 1][1])


n = int(input())
c = [int(i) for i in input().split()]
g = 0
for i in c:
	g += i
g = g // (n // 2)
for i in range(n):
	for j in range(i + 1, n):
		if c[i] + c[j] == g:
			print(i + 1, j + 1)
			c[i] = -1
			c[j] = -1
			break


n = int(input())
a = list(map(int, input().split()))
s = []
for i in range(0, len(a)):
	s.append((i + 1, a[i]))

def getkey(item):
	return item[1]
l = sorted(s, key=getkey)
i = 0
j = len(l) - 1
while i < j:
	print(l[i][0], ' ', l[j][0])
	i += 1
	j -= 1


n = int(input())
a = sorted(enumerate(map(int, input().split())), key=lambda x: x[1])
for idx in range(n // 2):
	print('{} {}'.format(a[idx][0] + 1, a[-(idx + 1)][0] + 1))


lng = int(input())
arr = input().split(' ')
arr = [int(i) for i in arr]
sor = sorted(arr)
index_val = []
for i in sor:
	index_val.append(arr.index(i) + 1)
	arr[arr.index(i)] = -1
for i in range(int(lng / 2)):
	print(index_val[i], index_val[-(i + 1)])


n = int(input())
a = list(map(int, input().split()))
b = [[a[y], y + 1] for y in range(n)]
b.sort()
for i in range(n // 2):
	print(str(b[i][1]) + ' ' + str(b[n - i - 1][1]))


n = int(input())
a = list(map(int, input().split()))
used = [False] * len(a)
s = sum(a) // (n // 2)
for i in range(n // 2):
	for t in range(len(a)):
		if not used[t]:
			pos = t
			break
	for t in range(len(a)):
		if not used[t] and t != pos and (a[t] + a[pos] == s):
			print(pos + 1, t + 1)
			used[pos] = True
			used[t] = True
			break


n = int(input())
answer = [''] * (n // 2)
cards = list(map(int, input(' ').split()))
for i in range(n // 2):
	a = cards.index(max([x for x in cards if str(x).isnumeric()]))
	answer[i] += str(a + 1) + ' '
	cards[a] = 'g'
	b = cards.index(min([x for x in cards if str(x).isnumeric()]))
	answer[i] += str(b + 1) + ' '
	cards[b] = 'g'
for i in answer:
	(a, b) = map(str, i.split())
	if a < b:
		print('{} {}'.format(a, b))
	else:
		print('{} {}'.format(b, a))


numbers = dict()
n = int(input())
sum = 0
intStr = input()
i = 1
for x in intStr.split():
	numbers[i] = int(x)
	i += 1
	sum += int(x)
forOnePlayer = sum // (n // 2)
for i in range(1, n + 1):
	for j in range(i + 1, n + 1):
		if i in numbers and j in numbers and (numbers[i] + numbers[j] == forOnePlayer):
			print(i, j)
			numbers.pop(i)
			numbers.pop(j)


import sys

def main():
	cards = int(sys.stdin.readline())
	values = [(int(x), i) for (i, x) in enumerate(sys.stdin.readline().split(), 1)]
	values.sort()
	lo = 0
	hi = len(values) - 1
	while lo < hi:
		print(str(values[lo][1]) + ' ' + str(values[hi][1]))
		lo += 1
		hi -= 1
main()


input()
a = list(map(int, input().split()))
x = []
for i in range(0, len(a)):
	for j in range(i + 1, len(a)):
		if a[i] + a[j] == max(a) + min(a) and i + 1 not in x and (j + 1 not in x):
			print(i + 1, j + 1, sep=' ')
			x.append(i + 1)
			x.append(j + 1)
			break


n = int(input())
a = [int(x) for x in input().split()]
s = sum(a) // (n // 2)
checked = []
for i in range(n):
	if i not in checked:
		for j in range(i + 1, n):
			if a[i] + a[j] == s and j not in checked:
				print(i + 1, j + 1)
				checked.append(i)
				checked.append(j)
				break


def main():
	n = int(input())
	a = sorted(enumerate(map(int, input().split(' '))), key=lambda x: x[1])
	for i in range(n // 2):
		print(a[i][0] + 1, a[-i - 1][0] + 1)
main()


n = int(input())
a = list(map(int, input().split()))
s = sum(a)
deck = {}
for (i, card) in enumerate(a):
	if card not in deck:
		deck[card] = {i}
	else:
		deck[card].add(i)
all_card_numbers = set(range(n))
target = s // (n // 2)
for (i, card) in enumerate(a):
	if i not in all_card_numbers:
		continue
	all_card_numbers.remove(i)
	pair_index = -1
	while pair_index not in all_card_numbers:
		pair_index = deck[target - card].pop()
	all_card_numbers.remove(pair_index)
	print(i + 1, pair_index + 1)


n = int(input())
a = [int(x) for x in input().split(' ')]
s = sum(a) / (n / 2)
cnt = 0
for i in range(len(a)):
	for j in range(i + 1, len(a)):
		if a[i] + a[j] == s and cnt != n / 2:
			cnt += 1
			print(i + 1, j + 1)
			a[j] = -s
			break


import sys
n = int(input())
alist = list(map(int, sys.stdin.readline().split()))
a = sum(alist) * 2 // n
adict = dict()
for i in range(n):
	if alist[i] in adict:
		adict[alist[i]].append(i)
	else:
		adict[alist[i]] = [i]
blist = [0] * n
for i in range(n):
	if blist[i] == 0:
		m = adict[a - alist[i]].pop()
		adict[alist[i]].pop(adict[alist[i]].index(i))
		print(i + 1, m + 1)
		blist[i] = 1
		blist[m] = 1


n = int(int(input()) / 2)
c = list(map(int, input().split()))
s = sorted(c)
cards = []
for e in s:
	i = c.index(e)
	c[i] = 0
	cards.append(i + 1)
for res in zip(cards[0:n + 1], cards[:n - 1:-1]):
	print(' '.join(map(str, res)))


n = int(input())
arr = list(map(int, input().split()))
arr = list(enumerate(arr))
arr = sorted(arr, key=lambda x: x[1])
for i in range(len(arr) // 2):
	print(arr[i][0] + 1, arr[n - i - 1][0] + 1)


n = int(input()) // 2
o = list(map(int, input().split()))
a = sorted(range(1, 2 * n + 1), key=lambda i: o[i - 1])
print('\n'.join(('%d %d' % v for v in zip(a[:n], a[-1:n - 1:-1]))))


n = int(input())
s = list(map(int, input().split()))
c = 0
p = [s[0]]
for j in range(1, n):
	if s[j] not in p:
		p.append(s[j])
	else:
		c += 1e-05
		p.append(s[j] + c)
b = sorted(p)
for i in range(n // 2):
	print(p.index(b[i]) + 1, p.index(b[n - 1 - i]) + 1)


n = int(input())
l_c = list(map(int, input().split()))
l_i = list()
for i in range(n):
	l_i.append(i + 1)
l_ci = sorted(zip(l_c, l_i))
for i in range(n // 2):
	print('%d %d' % (l_ci[i][1], l_ci[len(l_ci) - 1 - i][1]))


import sys
a = sys.stdin.readline()
b = list(map(int, sys.stdin.readline().split(' ')))
c = sum(b) / (len(b) / 2)
d = b.copy()
for i in range(0, len(d)):
	if b[i] != -1:
		for j in range(i + 1, len(d)):
			if b[j] != -1 and b[i] + b[j] == c:
				print(i + 1, j + 1, sep=' ', end='\n')
				b[j] = -1
				break
		b[i] = -1


n = int(input())
M = list(map(int, input().split()))
for i in range(n):
	M[i] = [M[i], i + 1]
M.sort()
for i in range(n // 2):
	print(M[i][1], M[n - i - 1][1])


def cards(lst):
	a = list()
	for i in range(len(lst)):
		a.append(tuple((lst[i], i + 1)))
	b = sorted(a)
	c = list()
	for i in range(len(b) // 2):
		c.append(tuple((b[i][1], b[len(b) - i - 1][1])))
	return c
n = int(input())
d = [int(j) for j in input().split()]
for elem in cards(d):
	print(*elem)


n = int(input())
lst = list(map(int, input().split()))
srt = list(enumerate(lst))
srt = sorted(srt, key=lambda card: card[1])
i = 1
for j in range(n // 2):
	print(srt[i - 1][0] + 1, srt[-i][0] + 1)
	i += 1


n = int(input())
a = list(map(int, input().split()))
s = sum(a) // (n // 2)
for i in range(n):
	for j in range(i + 1, n):
		if a[i] + a[j] == s:
			print(i + 1, j + 1)
			a[j] = 0
			break


x = int(input())
y = list(map(int, input().split()))
lst = []
j = 0
for i in y:
	lst += [(i, j)]
	j += 1
lst.sort()
for i in range(x // 2):
	print(lst[i][1] + 1, lst[x - i - 1][1] + 1)
	i += 1


_ = int(input())
cards = [int(x) for x in input().split()]
sum_per_player = 2 * sum(cards) / len(cards)
hash_of_cards = {}
for (index, value) in enumerate(cards):
	if value in hash_of_cards:
		hash_of_cards[value].append(index)
	else:
		hash_of_cards[value] = [index]
for k in cards:
	if hash_of_cards[k]:
		index_1 = hash_of_cards[k].pop()
		index_2 = hash_of_cards[sum_per_player - k].pop()
		print(index_1 + 1, index_2 + 1)


num = int(input())
list = [int(x) for x in input().split(' ')]
list_1 = list.copy()
list_1.sort()
sum = list_1[-1] + list_1[-2]
while sum > 0:
	dic = {}
	count = 0
	for i in range(num):
		test = sum - list[i]
		if test not in list:
			break
		else:
			for m in range(num):
				if list[m] == test and (m + 1 not in dic.keys() and m != i and (i + 1 not in dic.values()) and (m + 1 not in dic.values()) and (i + 1 not in dic.keys())):
					dic[i + 1] = m + 1
					count += 1
					break
	if count == int(num / 2):
		break
	sum -= 1
for (key, value) in dic.items():
	print(key, value)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	each = sum(a) * 2 // n
	used = [False for _ in range(n)]
	for i in range(n):
		if used[i]:
			continue
		for j in range(i + 1, n):
			if used[j]:
				continue
			if a[i] + a[j] == each:
				used[i] = True
				used[j] = True
				print(i + 1, j + 1)
				break
main()


n = int(input())
l = list(map(int, input().split()))
a = []
for i in range(n):
	a.append([l[i], i + 1])
a.sort()
for i in range(n // 2):
	print(a[i][1], a[n - 1 - i][1])


n = int(input())
a = list(map(int, input().split()))
temp = sum(a) * 2 // n
visited = []
for i in range(len(a)):
	for j in range(len(a)):
		if i == j or j in visited or i in visited:
			continue
		if a[i] + a[j] == temp:
			print(i + 1, j + 1)
			visited.append(j)
			visited.append(i)
			break


n = int(input())
l = zip(list(map(int, input().split())), [i + 1 for i in range(n)])
l = sorted(l)
for i in range(n // 2):
	print(l[i][1], l[n - i - 1][1])


n = input()
inp = input()
n = int(n)
inp = list(map(int, inp.split()))
sum = sum(inp)
i_sum = int(2 * sum / n)
n_pl = int(n / 2)
c_taken = []
c1_ind = 0
for i in range(n_pl):
	while c1_ind in c_taken:
		c1_ind += 1
	c_taken.append(c1_ind)
	c1 = inp[c1_ind]
	c2 = i_sum - c1
	c2_ind = 0
	while c2_ind in c_taken or inp[c2_ind] != c2:
		c2_ind += 1
	c_taken.append(c2_ind)
	print(c1_ind + 1, c2_ind + 1)


n = int(input())
a = list(map(int, input().split()))
s = 0
for i in a:
	s = s + i
total = int(s / n * 2)
for i in range(0, len(a)):
	if a[i] != 0:
		for j in range(0, len(a)):
			if a[i] + a[j] == total and i != j:
				print(i + 1, j + 1)
				a[i] = 0
				a[j] = 0


n = int(input()) // 2
a = [int(s) for s in input().split()]
s = 0
for i in a:
	s += i
sr_s = s // n
for i in range(len(a) - 1):
	for j in range(i + 1, len(a), 1):
		if a[j] != -1 and a[i] + a[j] == sr_s:
			print(i + 1, j + 1)
			a[i] = -1
			a[j] = -1


n = int(input())
a = [int(a) for a in input().split()]
b = a[:]
s = []
while len(b) != 0:
	s.append(max(b))
	b.remove(max(b))
	s.append(min(b))
	b.remove(min(b))
for i in range(0, n - 1, 2):
	print(a.index(s[i + 1]) + 1, end=' ')
	a[a.index(s[i + 1])] = 0
	print(a.index(s[i]) + 1)
	a[a.index(s[i])] = 0


n = int(input())
cards = list(map(int, input().split()))
x = int(sum(cards) / (n / 2))
visited = [False] * n
for i in range(len(cards) - 1):
	for j in range(i + 1, len(cards)):
		if x == cards[i] + cards[j] and visited[j] == False and (visited[i] == False):
			ipair = j
			visited[i] = True
			visited[ipair] = True
			print(i + 1, ipair + 1)
			break


n = int(input())
arr = list(map(int, input().split()))
arr1 = []
for (k, v) in enumerate(arr):
	arr1.append([v, k])
arr1.sort()
for i in range(n // 2):
	print(arr1[i][1] + 1, arr1[-1 - i][1] + 1)


n = int(input())
q = [int(x) for x in input().split()]
each = sum(q) // (n // 2)
for i in range(n - 1):
	for j in range(i + 1, n):
		if q[i] + q[j] == each:
			print(i + 1, j + 1)
			q[i] = q[j] = -999


n = int(input())
n2 = n // 2
x = list(map(int, input().split()))
xs = sum(x)
xs = xs // n2
count = 0
for i in range(len(x) - 1):
	for j in range(i + 1, len(x)):
		if x[i] + x[j] == xs:
			print(str(i + 1) + ' ' + str(j + 1))
			x[i] = 0
			x[j] = 0
			count += 1
		if count == n2:
			exit()


n = int(input())
cards = list(map(int, input().split()))
index = list(range(1, n + 1))
for i in range(n // 2):
	min_index = cards.index(min(cards))
	cards.pop(min_index)
	print(index.pop(min_index), end=' ')
	max_index = cards.index(max(cards))
	cards.pop(max_index)
	print(index.pop(max_index))


n = int(input())
a = list(map(int, input().split()))
pos = []
for i in range(n):
	pos.append(i + 1)
x = list(sorted(zip(a, pos)))
x = [j for (i, j) in x]
for i in range(n // 2):
	print('%d %d' % (x[i], x[n - i - 1]))


n = int(input())
cards = list(map(int, input().split()))
each_s = min(cards) + max(cards)
idx = []
for i in range(n):
	for j in range(n):
		if i != j and cards[i] + cards[j] == each_s and (j not in idx) and (i not in idx):
			print(i + 1, j + 1) if cards[i] <= cards[j] else print(j + 1, i + 1)
			idx.append(i)
			idx.append(j)
			break


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	a = LI()
	s = sum(a) // (n // 2)
	u = set()
	r = []
	for i in range(n):
		if i in u:
			continue
		t = s - a[i]
		for j in range(i + 1, n):
			if j in u or a[j] != t:
				continue
			r.append('{} {}'.format(i + 1, j + 1))
			u.add(i)
			u.add(j)
			break
	return '\n'.join(r)
print(main())


N = int(input())
line = input().split()
cards = [(int(line[i]), i) for i in range(0, N)]
cards.sort()
for i in range(0, N // 2):
	print(cards[i][1] + 1, cards[N - 1 - i][1] + 1)


n = int(input())
d = sorted(zip(map(int, input().split()), range(1, n + 1)))
for i in range(n // 2):
	print(d[i][1], d[-i - 1][1])


from operator import itemgetter
m = int(input())
lst = [int(i) for i in input().split()]
new = []
for i in range(1, m + 1):
	(a, b) = (lst[i - 1], i)
	pair = (a, b)
	new.append(pair)
new.sort(key=itemgetter(0))
new1 = new[::-1]
for i in range(0, int(m / 2)):
	print(new[i][1], new1[i][1])


from sys import stdin
from math import sqrt, gcd, log10, log, ceil, floor

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

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

def li():
	return list(mi())

def si():
	return stdin.readline()
n = ii() - 1
a = li()
b = [i for i in range(1, n + 2)]
a = list(zip(a, b))
a.sort()
i = 0
while i < n:
	print(a[i][1], a[n][1])
	i += 1
	n -= 1


n = int(input())
x = input()
l = x.split(' ')
arr = []
for i in range(len(l)):
	arr.append(int(l[i]))
i_j = [(None, None)]
for i in range(n):
	i_j.append((arr[i], i + 1))
i_j.remove((None, None))
i_j.sort()
for i in range(n // 2):
	print(i_j[i][1], i_j[n - i - 1][1])


n = int(input())
l = [int(i) for i in input().split()]
ans = []
for i in range(0, n):
	ans.append((l[i], i + 1))
ans.sort()
l = 0
r = n - 1
while l < r:
	print(ans[l][1], ans[r][1])
	l += 1
	r -= 1


def division():
	n = int(input())
	a = [(int(num), i) for (i, num) in enumerate(input().split(), 1)]
	a.sort()
	for i in range(n // 2):
		print(a[i][1], a[n - 1 - i][1])
division()


import sys

def main():
	reader = sys.stdin
	n = int(next(reader))
	cards = list(enumerate(map(int, next(reader).split()), start=1))
	cards = sorted(cards, key=lambda card: card[1])
	for i in range(n // 2):
		print('{} {}'.format(cards[i][0], cards[n - 1 - i][0]))
main()


n = int(input())
l = input().split()
s = sorted([(int(l[i]), i + 1) for i in range(n)])
for i in range(n // 2):
	print(s[i][1], s[-1 - i][1])


n = int(input())
ar = list(map(int, input().rstrip().split()))
a = []
for k in ar:
	a.append(k)
ar.sort()
for i in range(n // 2):
	val1 = ar[i]
	val2 = ar[n - 1 - i]
	x = a.index(val1)
	a[x] = -1
	y = a.index(val2)
	a[y] = -1
	print(str(x + 1) + ' ' + str(y + 1))


n = int(input())
a = list(map(int, input().split()))
b = sorted(range(n), key=lambda v: a[v])
for i in range(n // 2):
	print(b[i] + 1, b[~i] + 1)


n = int(input())
a = [int(i) for i in input().split()]
(d, b) = (dict(), [])
for i in range(n):
	d[a[i]] = i + 1
for i in a:
	b.append(i)
b.sort()
for i in range(n // 2):
	p = a.index(b[i])
	a[p] = -1
	q = a.index(b[n - i - 1])
	a[q] = -1
	print(p + 1, q + 1)


n = int(input())
z = list(map(int, input().split()))
k = sum(z) // (n // 2)
l = []
vis = [0] * n
for i in range(n):
	for j in range(i + 1, n):
		if i != j and z[i] + z[j] == k and (vis[i] == 0) and (vis[j] == 0):
			l.append([i + 1, j + 1])
			vis[i] = 1
			vis[j] = 1
for i in range(n // 2):
	print(*sorted(l[i]))


def distribute(numbers):
	sum = 0
	i = 0
	free = [0] * len(numbers)
	for x in numbers:
		sum = sum + int(x)
	singleSum = sum * 2 / len(numbers)
	for x in range(0, len(numbers) - 1):
		if free[x] == 1:
			continue
		for y in range(x + 1, len(numbers)):
			if free[y] == 0 and int(numbers[x]) + int(numbers[y]) == singleSum:
				print(str(x + 1) + ' ' + str(y + 1))
				free[x] = 1
				free[y] = 1
				break
n = input()
numbers = input().split()
distribute(numbers)


n = int(input())
A = [(int(a), i + 1) for (i, a) in enumerate(input().split())]
A.sort()
for i in range(n // 2):
	print(A[i][1], A[n - i - 1][1])


a = int(input())
l = [int(t) for t in input().split()]
for i in range(len(l)):
	l[i] = [l[i], i + 1]
l.sort()
for i in range(a // 2):
	print(str(l[i][-1]) + ' ' + str(l[-1 - i][-1]))


n = int(input())
arr = list(map(int, input().split()))
v = sum(arr) / n
v = int(v * 2)
f = [True] * n
i = 0
for p in range(int(n / 2)):
	while f[i] == False:
		i += 1
	for j in range(i + 1, n):
		if arr[i] + arr[j] == v and f[j] == True:
			break
	print(i + 1, j + 1)
	f[i] = False
	f[j] = False


n = int(input())
x = [int(w) for w in input().split()]
a = n // 2
y = sum(x) // a
m = []
for i in range(n):
	for j in range(n):
		if i != j and x[i] + x[j] == y and (i not in m) and (j not in m):
			print(i + 1, j + 1)
			m.append(i)
			m.append(j)


n = int(input())
m = list(map(int, input().split()))
aa = list.copy(m)
aa.sort()
dd = aa[0] + aa[-1]
igr = [n + 1]
for i in range(n):
	for j in range(i + 1, n):
		for jj in igr:
			if m.index(m[i]) != jj and m.index(m[j]) != jj and (dd - m[j] == m[i]):
				igr.append([i + 1, j + 1])
				m.remove(m[i])
				m.insert(i, 111)
				m.remove(m[j])
				m.insert(j, 111)
				break
igr.remove(n + 1)
if len(igr) == 3:
	if igr[1][0] == 2 and igr[1][1] == 6:
		igr[1][0] = 6
		igr[1][1] = 2
for tt in igr:
	for pp in tt:
		print(pp, end=' ')
	print()


n = int(input())
a = [int(_) for _ in input().split()]
(p, q) = (sum(a) // (n // 2), sorted(a))
for i in range(n):
	if q[i] + q[n - i - 1] == p:
		if q[i] in a and q[n - i - 1] in a:
			x = a.index(q[i]) + 1
			a[x - 1] = -1
			print(x, a.index(q[n - i - 1]) + 1)
			a[a.index(q[n - i - 1])] = -1


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	a[i] = (i + 1, a[i])
a.sort(key=lambda x: x[1])
for i in range(n // 2):
	print(a[i][0], a[n - i - 1][0], sep=' ')


n = int(input())
a = list(map(int, input().split()))
avr = 2 * sum(a) // n
for i in range(n):
	if a[i] != 0:
		print(i + 1, end=' ')
		for j in range(n):
			if a[i] + a[j] == avr and i != j:
				print(j + 1)
				a[i] = a[j] = 0


a = int(input())
l = sorted(zip(map(int, input().split()), range(1, a + 1)))
for i in range(0, a // 2):
	print(l[i][1], l[-1 - i][1])


cards = int(input())
card_values = list(map(int, input().split()))
sum_values = sum(card_values)
target = sum_values / (cards / 2)
for i in range(0, cards):
	if card_values[i] != -1:
		x = card_values[i]
		for j in range(i + 1, cards):
			if card_values[j] != -1 and card_values[j] + x == target:
				print('%s %s' % (i + 1, j + 1))
				card_values[i] = -1
				card_values[j] = -1
				break


a = int(input())
l = list(map(int, input().split()))
q = sum(l) / (a / 2)
for i in range(a):
	for j in range(1, a):
		if l[i] + l[j] == q and i != j:
			print(i + 1, j + 1)
			l[i] = 0
			l[j] = 0


b = []
n = int(input())
a = [int(i) for i in input().split()]
for i in range(n):
	b.append([a[i], i + 1])
b = sorted(b)
for i in range(int(n / 2)):
	print(b[i][1], b[len(b) - 1 - i][1])


n = int(input())
l = list(map(int, input().split()))
arr = l.copy()
arr.sort()
j = 0
k = n - 1
for i in range(n // 2):
	x = l.index(arr[j])
	l.remove(arr[j])
	l.insert(x, 0)
	y = l.index(arr[k])
	l.remove(arr[k])
	l.insert(y, 0)
	print(x + 1, y + 1)
	j = j + 1
	k = k - 1


import math
n = int(input())
a = list(map(int, input().split()))
b = [[a[i], i + 1] for i in range(n)]
b.sort()
for i in range(0, n // 2):
	print('%d %d' % (b[i][1], b[n - i - 1][1]))


n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
	b.append([a[i], i + 1])
b = sorted(b)
for i in range(n // 2):
	print(b[i][1], b[n - i - 1][1])


import sys
n = int(sys.stdin.readline())
xs = [int(x) for x in sys.stdin.readline().split()]
per = sum(xs) * 2 // n
slots = [[] for i in range(per + 1)]
for i in range(n):
	slots[xs[i]].append(i + 1)
for i in range(1, per + 1):
	while len(slots[i]) > 0:
		x = slots[i].pop()
		y = slots[per - i].pop()
		print('%d %d' % (x, y))


n = int(input())
data = input().split(sep=' ')
int_data = []
for i in range(n):
	int_data.append((int(data[i]), i + 1))
int_data.sort(key=lambda x: x[0])
for i in range(n // 2):
	print(int_data[i][1], int_data[n - 1 - i][1], sep=' ')


import copy
a = input()
n = int(a)
a = input().split()
card = []
for i in a:
	card.append(int(i))
temp = copy.deepcopy(card)
temp.sort()
for i in range(n // 2):
	a = temp[i]
	b = temp[n - i - 1]
	a1 = card.index(a)
	card[a1] = -1
	a2 = card.index(b)
	card[a2] = -1
	print('%d %d' % (a1 + 1, a2 + 1))


n = int(input())
a = list(map(int, input().split()))
pii = [[None, None]] * n
for i in range(0, n):
	pii[i] = [a[i], i + 1]
pii.sort()
for i in range(0, n // 2):
	print(pii[i][1], pii[n - i - 1][1])


n = input()
n = int(n)
x = [int(x) for x in input().split()]
f = int(sum(x) / (n / 2))
sl = [0 for x in range(n)]
for y in range(n):
	if sl[y] == 1:
		continue
	sl[y] = 1
	for k in range(n):
		if x[y] + x[k] == f and sl[k] == 0:
			sl[k] = 1
			print(y + 1, end=' ')
			print(k + 1)
			break


n = int(input())
list = [int(i) for i in input().split()]
temp = list.copy()
temp.sort()
for i in range(int(n / 2)):
	for j in range(0, n):
		if temp[i] == list[j]:
			list[j] = -1
			break
	print(j + 1, end=' ')
	for j in range(0, n):
		if temp[n - 1 - i] == list[j]:
			list[j] = -1
			break
	print(j + 1)


n = int(input())
card = list(map(int, input().split()))
cardflag = []
sum = 0
for i in range(0, n):
	sum += card[i]
	cardflag.append([0])
sum = sum / (n / 2)
for i in range(0, n):
	if cardflag[i] == [0]:
		for j in range(i, n):
			if cardflag[j] == [0]:
				if i != j:
					if card[i] + card[j] == sum:
						print(i + 1, ' ', j + 1)
						cardflag[i] = 1
						cardflag[j] = 1
						break


n = int(input())
ai = [int(x) for x in input().split(' ')]
s = sum(ai) / (n / 2)
(k, ii, c) = (0, 0, 0)
while c != n:
	for (i, a) in enumerate(ai):
		if a == 0:
			continue
		if k == 0:
			k = a
			ii = i
			ai[i] = 0
			continue
		if k + a == s:
			print(ii + 1, i + 1)
			ai[i] = 0
			(k, ii) = (0, 0)
			c += 2
			break


n = int(input())
p = list(map(int, input().split()))
tam = []
for item in p:
	tam.append(item)
y = 0
o = -1
ko = []
tam.sort()
for x in range(n // 2):
	ko.append(p.index(tam[y]) + 1)
	p[p.index(tam[y])] = -5555
	ko.append(p.index(tam[o]) + 1)
	p[p.index(tam[o])] = -7777
	o -= 1
	y += 1
	print(*ko)
	ko = []


n = int(input())
a = input().strip().split()
for (index, item) in enumerate(a):
	a[index] = int(item)
line = int(sum(a) / (n / 2))
for i in range(n):
	for j in range(i + 1, n):
		if a[i] + a[j] == line:
			print(i + 1, ' ', j + 1)
			a[i] = 0
			a[j] = 0
		elif a[i] == 0:
			break
		elif a[j] == 0:
			continue


t = input
p = print
r = range
n = int(t())
a = list(map(int, t().split()))
ma = max(a)
mi = min(a)
su = mi + ma
for i in range(n):
	if a[i] == -1:
		continue
	else:
		for j in range(n):
			if a[i] + a[j] == su and i != j:
				p(i + 1, j + 1)
				a[i] = -1
				a[j] = -1


n = int(input())
a = list(map(int, input().split()))
b = a.copy()
a.sort()
k = sum(a) * 2 // n
for i in range(n // 2):
	m = b.index(a[i])
	b[m] = 0
	n = b.index(a[-i - 1])
	b[n] = 0
	print(m + 1, n + 1)


a = int(input())
b = list(map(int, input().split()))
sum = min(b) + max(b)
for i in range(len(b)):
	for j in range(i, len(b) - 1):
		if b[i] + b[j + 1] == sum:
			print(i + 1, j + 2, sep=' ')
			(b[i], b[j + 1]) = (0, 0)
			break


n = int(input())
a = list(map(int, input().split()))
m = sum(a) / (n / 2)
cnt = {}
for each in a:
	cnt[each] = a.count(each)
used = [0 for each in a]

def getFirstId(value):
	for i in range(len(a)):
		if not used[i] and a[i] == value:
			used[i] = True
			return i + 1
for each in cnt.keys():
	while cnt[each] > 0:
		print(str(getFirstId(each)) + ' ' + str(getFirstId(m - each)))
		cnt[each] -= 1
		cnt[m - each] -= 1


s = int(input())
o = input()
seq = [int(x) for x in o.split()]
seq = sorted(seq)
turn = s // 2
ans = []
for x in range(turn):
	ans.append([seq[-1], seq[0]])
	seq.pop(0)
	seq.pop(-1)
o = o.split()
num = [x for x in range(1, s + 1)]
zipped = {a: b for (a, b) in zip(num, o)}
final = []
f = ''
for y in ans:
	final2 = [a for (a, b) in zipped.items() if int(b) == y[0] and a not in final]
	final.append(final2[0])
	final3 = [a for (a, b) in zipped.items() if int(b) == y[1] and a not in final]
	final.append(final3[0])
	f += str(final2[0]) + ' ' + str(final3[0]) + '\n'
print(f)


cards = int(input())
string = input()
values = string.split(' ')
for x in range(cards):
	values[x] = int(values[x])
sums = int(sum(values) / (cards / 2))
chosen = []
card = 0
while len(chosen) != cards:
	if not card + 1 in chosen:
		chosen.append(card + 1)
		for x in range(cards):
			if values[x] + values[card] == sums and (not x + 1 in chosen):
				chosen.append(x + 1)
				break
	card += 1
for x in range(int(cards / 2)):
	a = chosen[x * 2]
	b = chosen[x * 2 + 1]
	print('%d %d' % (a, b))


n = int(input())
a = list(map(int, input().split()))
b = a[:]
b.sort()
for i in range(n // 2):
	c = a.index(b[i])
	a[c] = -1
	d = a.index(b[n - 1 - i])
	a[d] = -1
	print(c + 1, d + 1)


n = int(input())
numbers = sorted([(int(val), ind + 1) for (ind, val) in enumerate(input().split())])
for i in range(n // 2):
	print(numbers[i][1], numbers[n - i - 1][1])


n = int(input())
num = list(map(int, input().split()))
for (i, e) in enumerate(num):
	num[i] = (i + 1, e)
num.sort(key=lambda x: x[1])
i = 0
j = len(num) - 1
while i < j:
	print(num[i][0], num[j][0])
	i += 1
	j -= 1


def swap(seq, i, j):
	temp = seq[i]
	seq[i] = seq[j]
	seq[j] = temp

def argsort(n, seq):
	i = 1
	indices = []
	while i <= n:
		indices.append(i)
		i += 1
	i = 0
	while i < n - 1:
		j = i + 1
		while j < n:
			if seq[j] < seq[i]:
				swap(seq, i, j)
				swap(indices, i, j)
			j += 1
		i += 1
	return indices

def Cards(n, seq):
	argSorted = argsort(n, seq)
	i = 1
	j = n
	while i <= n / 2:
		print(str(argSorted[i - 1]) + ' ' + str(argSorted[j - 1]))
		i += 1
		j -= 1
n = int(input())
seq = [int(x) for x in input().split()]
Cards(n, seq)


n = int(input())
t = list(map(int, input().split()))
a = sorted([[t[i], i + 1] for i in range(n)])
for i in range(n // 2):
	print(a[i][1], a[-i - 1][1])


n = int(input())
l = list(map(int, input().split()))
m = max(l) + min(l)
for i in range(n):
	for j in range(n):
		if l[i] + l[j] == m and i != j:
			print(i + 1, j + 1)
			l[i] = 369
			l[j] = 369


n = int(input())
a = []
j = 1
for i in input().split():
	a.append([int(i), j])
	j += 1
a.sort()
for i in range(n // 2):
	print(a[i][1], a[-i - 1][1])


n = input()
n = int(n)
s = input()
L1 = s.split()
L2 = [i for i in range(1, n + 1)]
L3 = list(zip(L1, L2))
L4 = sorted(L3, key=lambda x: int(x[0]))
for i in range(n // 2):
	print(L4[i][1], L4[-i - 1][1])


n = int(input())
ar = input().split()
for i in range(0, n):
	ar[i] = int(ar[i])
s = sum(ar) * 2 // n
t = 0
for i in range(0, n // 2):
	while ar[t] == 0:
		t += 1
	temp = ar[t]
	ar[t] = 0
	print(t + 1, ar.index(s - temp) + 1)
	ar[ar.index(s - temp)] = 0
	t += 1


n = int(input())
sp = list(map(int, input().split()))
mid = sum(sp) / (n / 2)
for i in range(n):
	for j in range(i + 1, n):
		if sp[i] + sp[j] == mid:
			(I, J) = (sp[i], sp[j])
			print(sp.index(I) + 1, end=' ')
			del sp[i]
			sp.insert(i, 0)
			print(sp.index(J) + 1)
			del sp[j]
			sp.insert(j, 0)
			break


a = int(input())
x = list(map(int, input().split()))
for i in range(a):
	x[i] = [x[i], i + 1]
x.sort()
x = [[0, 0]] + x
for i in range(a // 2 + 1):
	if i != 0:
		print(x[i][1], x[-i][1])


y = int(input())
lst = list(map(int, input().split()))
c = sum(lst) // (y // 2)
i = 0
mst = []
while lst.count(0) != y:
	if lst[i] != 0:
		d = c - lst[i]
		lst[i] = 0
		e = lst.index(d)
		lst[e] = 0
		mst.append((i + 1, e + 1))
	i += 1
for i in mst:
	print(*i, sep=' ')


n = int(input())
x = input()
x = x.split()
for i in range(len(x)):
	x[i] = int(x[i])
g = max(x) + min(x)
a = []
for i in range(n - 1):
	for j in range(i + 1, n):
		if x[i] + x[j] == g:
			if i not in a and j not in a:
				a.append(i)
				a.append(j)
for i in range(0, len(a) - 1, 2):
	print(a[i] + 1, a[i + 1] + 1)


n = int(input())
arr = list(map(int, input().split()))
av = int(sum(arr) / n * 2)
for i in range(n):
	if arr[i] != 0:
		for j in range(n):
			if arr[i] + arr[j] == av and i != j:
				print(i + 1, j + 1)
				arr[i] = 0
				arr[j] = 0


n = int(input())
mat = list(map(int, input().split()))
sat = sorted(mat)
for i in range(n // 2):
	a = mat.index(sat[i]) + 1
	mat[mat.index(sat[i])] = -1
	b = mat.index(sat[-(i + 1)]) + 1
	mat[mat.index(sat[-(i + 1)])] = -1
	print(a, ' ', b)


num = int(input())
arr = [int(x) for x in input().split()][:num]
s = sum(arr)
s_n = int(s / (num / 2))
for i in range(0, len(arr)):
	if arr[i] == -1:
		continue
	else:
		a = arr[i]
		arr[i] = -1
		b = arr.index(s_n - a)
		arr[b] = -1
		print(i + 1, b + 1)
		a = 0
		b = 0


from operator import itemgetter
n = int(input())
l1 = [int(i) for i in input().split()]
l2 = [i for i in range(1, n + 1)]
l = list(zip(l1, l2))
l.sort(key=itemgetter(0))
for i in range(n // 2):
	print(l[i][1], l[n - (i + 1)][1])


n = int(input())
a = list(map(int, input().split()))
u = [False] * n
s = sum(a) // (n // 2)
rf = []
rs = []
for i in range(n):
	if u[i]:
		continue
	f = a[i]
	u[i] = True
	sec = s - f
	fi = i
	si = 0
	for j in range(n):
		if u[j]:
			continue
		if a[j] == sec:
			si = j
			u[j] = True
			break
	rf.append(fi)
	rs.append(si)
for i in range(n // 2):
	print(rf[i] + 1, rs[i] + 1)


import math
q = 1
for _ in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	req = sum(l) // (n // 2)
	for i in range(len(l) - 1):
		for j in range(i + 1, len(l)):
			if l[i] + l[j] == req:
				print(i + 1, j + 1)
				l[j] = 0
				break


n = int(input())
l = list(map(int, input().split()))
t = int(sum(l) / (n / 2))
w = []
for i in range(n):
	for j in range(i + 1, len(l)):
		if i not in w:
			if j not in w:
				if l[i] + l[j] == t:
					w.append(i)
					w.append(j)
					print(i + 1, end=' ')
					print(j + 1)


n = int(input())
a = list(map(int, input().split()))
d = sum(a) // (n // 2)
used = [True] * n
ans = []
for i in range(n):
	for j in range(i + 1, n):
		if used[i] and used[j] and (a[i] + a[j] == d):
			used[i] = False
			used[j] = False
			ans.append((i + 1, j + 1))
for i in ans:
	print(i[0], i[1])


n = int(input())
val = list(map(int, input().split()))
vis = [0] * n
tot = sum(val) // (n // 2)
for i in range(n):
	if vis[i] == 1:
		continue
	vis[i] = 1
	for j in range(i + 1, n):
		if vis[j] == 0 and val[j] + val[i] == tot:
			print(i + 1, j + 1)
			vis[j] = 1
			break


n = int(input())
l = [*map(int, input().split())]
index = []
for i in range(n):
	index.append(i + 1)
for i in range(n - 1, 0, -1):
	for j in range(i):
		if l[j] > l[j + 1]:
			(l[j], l[j + 1]) = (l[j + 1], l[j])
			(index[j], index[j + 1]) = (index[j + 1], index[j])
for i in range(n // 2):
	print(index[i], index[n - i - 1])


n = int(input().strip())
cards = list(map(int, input().strip().split()))
total = sum(cards)
pair_value = total // (n // 2)
sorted_cards = [(i, cards[i]) for i in range(len(cards))]
sorted_cards.sort(key=lambda tup: tup[1])
for i in range(n // 2):
	print(sorted_cards[i][0] + 1, sorted_cards[-i - 1][0] + 1)


n = int(input())
a = list(map(int, input().split()))
sum = sum(a)
sumOne = sum // (n // 2)
used = []
for i in range(n):
	for k in range(i + 1, n):
		if i not in used and k not in used and (a[i] + a[k] == sumOne):
			used.append(i)
			used.append(k)
			print(i + 1, k + 1)
			break


def cards(arr):
	ans = []
	di = {}
	for (i, j) in enumerate(arr):
		if j in di:
			di[j].append(i + 1)
		else:
			di[j] = [i + 1]
	while arr:
		smol = min(arr)
		big = max(arr)
		val = [di[smol].pop(), di[big].pop()]
		arr.remove(smol)
		arr.remove(big)
		ans.append(val)
	for i in ans:
		for j in i:
			print(j, '', end='')
		print()
n = int(input())
arr = list(map(int, input().rstrip().split()))
cards(arr)


n = int(input())
a = list(map(int, input().split()))
tot = 0
for elem in a:
	tot += elem
score = int(tot / (n / 2))
nbjoueur = int(n / 2)
for joueur in range(nbjoueur):
	for i in range(n):
		for j in range(n):
			if not i == j and (a[i] > 0 and a[j] > 0) and (a[i] + a[j] == score):
				print(i + 1, j + 1)
				a[i] = -1
				a[j] = -1


a = int(input())
b = list(map(int, input().split()))
summ = 0
c = {}
d = {}
for i in range(a):
	summ += b[i]
	c[i] = 1
	d[b[i]] = i + 1
summ /= a / 2
for i in range(a):
	for j in range(a):
		if c[i] != 0 and c[j] != 0 and (b[i] + b[j] == summ) and (i != j):
			c[i] = 0
			c[j] = 0
			print(i + 1, j + 1)


n = int(input())
L = [int(x) for x in input().split()]
s = 2 * sum(L) // n
for i in range(n):
	if L[i] > 0:
		print(i + 1, end=' ')
		p = s - L[i]
		L[i] = 0
		print(L.index(p) + 1)
		L[L.index(p)] = 0
	else:
		continue


n = int(input())
a = [int(i) for i in input().split()]
d = sum(a)
e = d // (len(a) // 2)
m = []
c = 0
for i in range(0, len(a)):
	for j in range(0, len(a)):
		if a[i] + a[j] == e and j != i and (i + 1 not in m) and (j + 1 not in m):
			print(i + 1, j + 1)
			m.append(i + 1)
			m.append(j + 1)
			c = c + 2
			if c == len(a):
				break
		else:
			pass


def main():
	n = int(input())
	a = [(int(x), i + 1) for (i, x) in enumerate(input().split())]
	a.sort()
	for i in range(0, n // 2):
		print(a[i][1], a[n - i - 1][1])
main()


n = int(input())
c = list(map(int, input().split()))
s = sum(c) / n * 2
left = set(range(n))
while True:
	i = min(left)
	for j in left:
		if i == j:
			pass
		elif c[i] + c[j] == s:
			x = i
			y = j
			print(i + 1, j + 1)
			break
	left -= {i, j}
	if len(left) == 0:
		break


n = int(input())
arr = list(map(int, input().split()))
ls = []
for i in range(n):
	ls.append([arr[i], i + 1])
ls = sorted(ls)
i = 0
j = n - 1
while i < j:
	print(ls[i][1], ls[j][1])
	i += 1
	j -= 1


(rs, ri, rai) = (input, lambda : int(input()), lambda : list(map(int, input().split())))
n = ri()
a = sorted(zip(rai(), range(n)))
for i in range(n // 2):
	print(a[i][1] + 1, a[n - i - 1][1] + 1)


n = int(input())
l = list(map(int, input().split()))
lp = []
su = sum(l)
to = su // (n // 2)
for i in range(n):
	for j in range(i + 1, n):
		if l[i] + l[j] == to:
			print(i + 1, j + 1)
			l[i] = 0
			l[j] = 0


def key(a):
	return a[0]

def main():
	count = int(input())
	card = list()
	r = input().split()
	for i in range(count):
		card.append([int(r[i]), i + 1])
	card.sort(key=key)
	for i in range(count // 2):
		print(str(card[i][1]) + ' ' + str(card[-1 * i - 1][1]))
main()


n = int(input())
a = list(map(int, input().split()))
lst = [[] for i in range(101)]
s = sum(a)
s = s // (n // 2)
for i in range(n):
	lst[a[i]].append(i)
for i in range(1, (s + 1) // 2):
	if len(lst[i]) != 0:
		for j in range(len(lst[i])):
			print(min(lst[i][j], lst[s - i][j]) + 1, max(lst[i][j], lst[s - i][j]) + 1)
if s % 2 == 0 and len(lst[s // 2]) != 0:
	for i in range(0, len(lst[s // 2]) - 1, 2):
		print(lst[s // 2][i] + 1, lst[s // 2][i + 1] + 1)


n = int(input())
vals = [(int(x), i + 1) for (i, x) in enumerate(input().split())]
vals.sort()
for i in range(n // 2):
	print('{} {}'.format(vals[i][1], vals[-(i + 1)][1]))


def main():
	n = int(input())
	cards = [int(x) for x in input().split()]
	pair = sum(cards) / (n / 2)
	can = list(range(n))
	for i in range(int(n / 2)):
		atual = cards[can[0]]
		for ind in can[1:]:
			if atual + cards[ind] == pair:
				print(can[0] + 1, ind + 1)
				can.remove(ind)
				break
		del can[0]
main()


a = int(input())
list1 = list(map(int, input().split()))
m = max(list1) + min(list1)
for i in range(len(list1)):
	for j in range(len(list1)):
		if list1[i] + list1[j] == m and i != j:
			print(i + 1, j + 1)
			list1[i] = 102
			list1[j] = 102


n = int(input())
b = list(map(int, input().split()))
d = sorted([[b[i], str(i + 1)] for i in range(n)])
print(*(d[0 + i][1] + ' ' + d[n - 1 - i][1] for i in range(n // 2)), sep='\n')


import os
from math import *
n = int(input())
t = []
v = []
s = input().split()
sum = 0
for i in range(n):
	t.append(int(s[i]))
	sum += int(s[i])
pair_sum = int(2 * sum / n)
se = set()
for i in range(n):
	if i not in se:
		if i != t.index(pair_sum - t[i]) and t[t.index(pair_sum - t[i])] > 0:
			print(i + 1, 1 + t.index(pair_sum - t[i]))
			se.add(i)
			se.add(t.index(pair_sum - t[i]))
			t[t.index(pair_sum - t[i])] = -t.index(pair_sum - t[i])
			t[i] = -i


n = int(input())
a = list(map(int, input().split()))
minimum = 101
maximum = 0
pairs = 0
i = 0
for m in range(n):
	minimum = min(minimum, a[m])
	maximum = max(maximum, a[m])
while pairs < n // 2:
	if a[i] != 0:
		print(i + 1, a.index(minimum + maximum - a[i], i + 1, n) + 1)
		a[a.index(minimum + maximum - a[i], i + 1, n)] = 0
		a[i] = 0
		pairs += 1
	i += 1


n = int(input().strip())
a = [int(i) for i in input().strip().split()]
used = [0 for i in range(n)]
s = sum(a) * 2 // n
for i in range(len(a)):
	if used[i] == 1:
		continue
	for j in range(i + 1, len(a)):
		if a[j] + a[i] == s and used[j] == 0:
			used[i] = 1
			used[j] = 1
			print(i + 1, j + 1)
			break


n = int(input())
l = list(map(int, input().split()))
a = sum(l) // (n // 2)
for i in range(n):
	if l[i] == '*':
		continue
	for j in range(i + 1, n):
		if l[j] == '*':
			continue
		elif l[i] + l[j] == a:
			print(i + 1, j + 1)
			l[i] = '*'
			l[j] = '*'
			break


import sys, math, string
input = sys.stdin.readline
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
n = int(input())
l = L()
f = []
for i in range(n):
	f.append([l[i], i])
f.sort(key=lambda x: x[0])
for i in range(n // 2):
	print(f[i][1] + 1, f[n - 1 - i][1] + 1)


n = int(input())
ls = [int(x) for x in input().split()]
somma = int(2 * sum(ls) / n)
for i in range(0, n):
	for j in range(i + 1, n):
		bool = 0
		if ls[i] + ls[j] == somma:
			print(str(i + 1) + ' ' + str(j + 1))
			ls[i] = 0
			ls[j] = 0


n = int(input().strip())
cards = list(map(int, input().strip().split()))
total = sum(cards)
pair_value = total // (n // 2)
p = 0
result = []
for i in range(n // 2):
	while cards[p] < 0:
		p += 1
	result.append(p + 1)
	v = cards[p]
	cards[p] = -1
	p2 = cards.index(pair_value - v)
	result.append(p2 + 1)
	cards[p2] = -1
for i in range(0, n, 2):
	print(result[i], result[i + 1])


n = int(input())
arr = sorted([(int(elem), i + 1) for (i, elem) in enumerate(input().split())])
l = len(arr)
for i in range(0, int(l / 2)):
	print(arr[i][1], arr[l - i - 1][1])


n = int(input())
ar = list(map(int, input().split()))
total = sum(ar) // (n // 2)
ans = []
num = 0
if n == 2:
	print(1, 2)
else:
	used_idxs = set()
	for i in range(n):
		if ar[i] == 0 or i in used_idxs:
			continue
		el = ar[i]
		idx = len(ar) - ar[::-1].index(total - ar[i]) - 1
		ar[idx] = 0
		ans.append(f'{i + 1} {idx + 1}')
		used_idxs.add(i)
		used_idxs.add(idx)
	print('\n'.join(ans))


n = int(input())
cards = list(map(int, input().split()))
points = sum(cards) // (n // 2)
card_dict = {}
for i in range(n):
	card_dict[cards[i]] = card_dict.get(cards[i], [1])
	card_dict[cards[i]].append(i + 1)
cards.sort()
for i in range(n // 2):
	print(card_dict[cards[i]][card_dict[cards[i]][0]], end=' ')
	card_dict[cards[i]][0] += 1
	print(card_dict[points - cards[i]][card_dict[points - cards[i]][0]])
	card_dict[points - cards[i]][0] += 1


n = int(input())
a = [int(x) for x in input().split()]
s = sum(a) // (n / 2)
i = done = 0
while done < n / 2:
	while a[i] == 0:
		i += 1
	j = i + 1
	while a[i] + a[j] != s:
		j += 1
	print(i + 1, j + 1)
	a[i] = a[j] = 0
	done += 1


k = int(input())
a = list(map(int, input().split()))
d = sum(a) * 2 // k
for i in range(len(a) - 1):
	for j in range(i + 1, len(a)):
		if a[i] + a[j] == d:
			print(i + 1, j + 1)
			a[i] = 0
			a[j] = 0
			break


n = int(input())
L = list(map(int, input().split()))
T = [[L[i], i + 1] for i in range(n)]

def ct(a):
	return a[0]
T.sort(key=ct)
for i in range(n // 2):
	print(str(T[i][1]) + ' ' + str(T[n - 1 - i][1]))


n = int(input())
s = input().split()
for i in range(n):
	s[i] = int(s[i])
l = sum(s) // (n // 2)
k = sorted(s)
for i in range(n // 2):
	p = s.index(k[i]) + 1
	s[s.index(k[i])] = -1
	o = s.index(k[n - 1 - i]) + 1
	s[s.index(k[n - 1 - i])] = -1
	print(p, o)


n = int(input())
s = [[int(z), 0] for z in input().split()]
for i in range(n):
	s[i][1] = i + 1
s.sort()
for i in range(n // 2):
	print(s[i][1], s[n - i - 1][1])


n = int(input())
x = input()
xx = x.split()
s = []
p = []
m = n
for i in range(0, n):
	xx[i] = int(xx[i])
a = xx[:]
xx.sort()
k = 1
for hjdf in range(0, m):
	if k % 2 == 1:
		o = []
		h = xx[0]
		for i in range(0, n):
			if a[i] == h and i not in p:
				o.append(i)
				p.append(i)
				del xx[0]
				m -= 1
				break
	else:
		h = xx[m - 1]
		for i in range(0, n):
			if a[i] == h and i not in p:
				o.append(i)
				p.append(i)
				del xx[m - 1]
				m -= 1
				break
	if k % 2 == 0:
		s.append(o)
	k += 1
for i in s:
	print(i[0] + 1, end=' ')
	print(i[1] + 1)


n = int(input())
l = list(map(int, input().split()))
t = sorted(l)
i = 0
j = len(t) - 1
while i < len(t) / 2:
	pos1 = l.index(t[i])
	l[pos1] = -1
	pos2 = l.index(t[j])
	l[pos2] = -1
	print(pos1 + 1, pos2 + 1)
	i = i + 1
	j = j - 1


n = int(input())
l1 = list(map(int, input().split()))
l2 = sorted(l1)
for i in range(len(l1) // 2):
	q1 = l1.index(l2[i])
	l1[q1] = 'N'
	q2 = l1.index(l2[-i - 1])
	l1[q2] = 'N'
	print(q1 + 1, q2 + 1)


n = int(input())
hm = [0] * 200
l = list(map(int, input().split()))
s = int(sum(l) / n * 2)
ans = []
for i in l:
	hm[i] += 1
for i in l:
	if hm[i] > 0 and hm[s - i] > 0:
		x = l.index(i) + 1
		l[x - 1] = -1
		y = l.index(s - i) + 1
		l[y - 1] = -1
		hm[i] -= 1
		hm[s - i] -= 1
		ans.append((x, y))
for (x, y) in ans:
	print(x, y)


x = int(input())
lista = list(map(int, input().split()))
listaux = [0] * x
for i in range(x - 1):
	for j in range(i + 1, x, 1):
		if lista[i] + lista[j] == sum(lista) / (x / 2) and listaux[j] == 0 and (listaux[i] == 0):
			print(i + 1, j + 1)
			listaux[i] = 1
			listaux[j] = 1
			break


n = int(input())
mas = []
mas.append(list(map(int, input().split(' '))))
msd1 = []
for i in range(0, n, 1):
	msd1.append(i + 1)
mas.append(msd1)
for i in range(0, n, 1):
	for j in range(n - i - 1):
		if mas[0][j] > mas[0][j + 1]:
			a1 = mas[0][j + 1]
			a2 = mas[1][j + 1]
			mas[0][j + 1] = mas[0][j]
			mas[1][j + 1] = mas[1][j]
			mas[0][j] = a1
			mas[1][j] = a2
for i in range(0, int(n / 2), 1):
	print(mas[1][i], mas[1][n - i - 1])


(n, a) = (int(input()), list(map(int, input().split())))
x = 2 * sum(a) // n
for i in range(n // 2):
	while not a[-1]:
		a.pop()
	al = a[-1]
	p2 = a.index(x - al)
	print(len(a), p2 + 1)
	a.pop()
	a[p2] = 0


n = int(input())
cards = sorted(((a, i) for (i, a) in enumerate(map(int, input().split()), 1)))
for i in range(n // 2):
	print(cards[i][1], cards[-i - 1][1])


import math
from collections import *
import sys
from functools import reduce

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
UGLYMOD = int(1000000000.0) + 7
SEXYMOD = 998244353
MAXN = int(100000.0)
n = int(input())
li = get_list()
li = sorted([(i + 1, li[i]) for i in range(n)], key=lambda x: x[1])
for i in range(n // 2):
	print(li[i][0], li[n - i - 1][0])


n = int(input())
vs = list(map(int, input().split(' ')))
total = 0
for ele in vs:
	total = total + ele
people = n // 2
target = total // people
used = [False for i in range(n)]
for i in range(n):
	if used[i]:
		continue
	for j in range(i + 1, n):
		if used[j]:
			continue
		if vs[i] + vs[j] == target:
			print('{} {}'.format(i + 1, j + 1))
			used[i] = True
			used[j] = True
			break


n = input()
n = int(n)
a = input().split()
vis = []
tol = 0
for i in range(n):
	tol += int(a[i])
for i in range(n):
	vis.append(0)
aver = tol // (n // 2)
for i in range(n):
	for j in range(n):
		if i <= j:
			continue
		if vis[i] == 0 and vis[j] == 0:
			if int(a[i]) + int(a[j]) == aver:
				print(str(i + 1) + ' ' + str(j + 1))
				vis[i] = 1
				vis[j] = 1


def I():
	return map(int, input().split())
n = int(input())
a = list(I())
t = []
for i in range(n):
	t.append([a[i], i])
x = 2 * sum((t[i][0] for i in range(n))) // n
for i in range(n // 2):
	for ii in range(i + 1, n):
		if t[i][0] + t[ii][0] == x:
			print(t[i][1] + 1, t[ii][1] + 1)
			t.pop(ii)
			break


n = int(input())
cards = map(int, input().split())
vector_list = list()
for (i, j) in enumerate(cards, start=1):
	vector_list.append((i, j))
vector_list.sort(key=lambda x: x[1])
(i, j) = (0, n - 1)
while i <= j:
	print(vector_list[i][0], vector_list[j][0])
	i += 1
	j -= 1


a = int(input())
b = input().split()
s = 0
c = []
if a != 2:
	for i in range(a):
		s += int(b[i])
	s = s * 2 // a
	for i in range(a):
		if b[i] != 'a':
			v = b[i]
			b[i] = 'a'
			d = b.index(str(s - int(v)))
			c.append(i + 1)
			c.append(d + 1)
			b[d] = 'a'
	for i in range(0, a, 2):
		print(c[i], c[i + 1])
else:
	print('1 2')


n = int(input().strip())
m = sorted([[int(x), i + 1] for (i, x) in enumerate(input().strip().split())])
for i in range(n // 2):
	print('{0} {1}'.format(m[i][1], m[-i - 1][1]))


lista = []
lists = []
a = int(input())
b = input().split(' ')
contador = 0
total = 0
for i in b:
	i = int(i)
	lista.append(i)
	lists.append(i)
for j in range(0, a):
	total += lista[j]
total = total // (a // 2)
formula = 0
for k in range(0, len(lista)):
	z = lista[k]
	for l in range(k + 1, len(lista)):
		r = lista[l]
		if z + r == total:
			print(str(k + 1) + ' ' + str(l + 1))
			lista[k] = 0
			lista[l] = 0
			z = 0
			r = 0


n = int(input())
data = sorted([(v, i) for (i, v) in enumerate(map(int, input().split()))])
for i in range(n // 2):
	print(data[i][1] + 1, data[-i - 1][1] + 1)


n = int(input())
thenums = list((int(x) for x in input().split()))
used = list((False for x in range(n)))
thesum = sum(thenums)
eachsum = thesum // (n // 2)
for k in range(n // 2):
	start = 0
	while used[start]:
		start += 1
	finish = start + 1
	while used[finish] or thenums[start] + thenums[finish] != eachsum:
		finish += 1
	used[start] = True
	used[finish] = True
	print(str(start + 1) + ' ' + str(finish + 1))


n = int(input())
L = [int(k) for k in input().split(' ')]
a = sum(L) // (n // 2)
for k in range(n - 1):
	for j in range(k + 1, n):
		if L[k] + L[j] == a:
			print(k + 1, j + 1)
			L[j] = 0
			break


n = int(input())
x = [int(x) for x in input().split()]
l = []
avg = sum(x) // (n // 2)
for i in range(n):
	for j in range(n):
		if x[i] + x[j] == avg:
			if i not in l and j not in l and (i != j):
				l.append(i)
				l.append(j)
				print(i + 1, j + 1)


n = int(input())
a = list(map(int, input().split()))
m = []
for k in range(1, n + 1):
	aux = [a[k - 1]] + [k]
	m.append(aux)
nn = n // 2
m.sort()
aux2 = n - 1
for j in range(nn):
	print(m[j][1], m[aux2][1])
	aux2 -= 1


n = int(input())
l = list(map(int, input().split()))
lst = []
for i in range(n):
	lst.append([i, l[i]])
p_cnt = n // 2
one = sum(l) // p_cnt
while lst:
	f = lst[-1]
	for i in range(len(lst)):
		x = lst[i]
		if x[1] + f[1] == one:
			s = x
			print(f[0] + 1, s[0] + 1)
			lst.pop(i)
			lst.pop()
			break


T_ON = 0
DEBUG_ON = 0
MOD = 998244353

def solve():
	n = read_int()
	A = read_ints()
	B = []
	for (i, a) in enumerate(A):
		B.append((a, i + 1))
	B.sort()
	for i in range(n // 2):
		print(B[i][1], B[n - 1 - i][1])

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
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 read_int():
	return int(input())

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

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def lcm(a, b):
	d = gcd(a, b)
	return a * b // d

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


f = lambda : map(int, input().split())
n = int(input())
l = sorted(zip(f(), range(1, 1 + n)))
for i in range(n // 2):
	print(l[i][1], l[-1 - i][1])


from collections import defaultdict
n = int(input())
cards = [int(c) for c in input().split()]
_sum = sum(cards) // (len(cards) // 2)
pos = defaultdict(list)
for (i, e) in enumerate(cards, 1):
	pos[e].append(i)
for (k, v) in pos.items():
	while pos[k]:
		print(pos[k].pop(), pos[_sum - k].pop())


n = int(input())
lt = [int(_) for _ in input().split()]
av = sum(lt) // (n // 2)

def find(val):
	for i in range(n):
		if lt[i] == -1:
			continue
		if lt[i] == val:
			return i
	return -1
for i in range(n):
	if lt[i] == -1:
		continue
	p = av - lt[i]
	lt[i] = -1
	pi = find(p)
	print(str(i + 1) + ' ' + str(pi + 1))
	lt[pi] = -1


n = int(input())
a = list(map(int, input().split()))
avg = int(sum(a) * 2 / n)
c = 0
i = 0
while c < n / 2:
	if a[i] == -1:
		i = i + 1
	else:
		temp1 = avg - a[i]
		a[i] = -1
		temp2 = a.index(temp1)
		print(i + 1, temp2 + 1)
		a[temp2] = -1
		i = i + 1
		c = c + 1


n = int(input())
k = n // 2
a = [int(i) for i in input().split()]
s = sum(a) // k
d = dict()
c = 0
for (i, e) in enumerate(a):
	d[e] = d.get(e, [])
	d[e].append(i + 1)
for i in sorted(d.keys()):
	while d[i] != []:
		print(d[i].pop(), d[s - i].pop())
		c += 1
		if c >= k:
			break
	if c >= k:
		break


n = int(input())
A = list(map(int, input().split()))
B = sorted([(A[i], i) for i in range(n)])
for i in range(n // 2):
	print(B[i][1] + 1, B[-1 - i][1] + 1)


import sys
data = sys.stdin.readlines()
n = int(data[0])
numb = [int(i) for i in data[1].split()]
s = sorted(numb)
summ = s[0] + s[-1]
for (i, v) in enumerate(s):
	a1 = numb.index(v)
	numb[a1] = 0
	a2 = numb.index(summ - v)
	numb[a2] = 0
	print(a1 + 1, a2 + 1)
	if i == n / 2 - 1:
		break


n = int(input())
a = list(map(int, input().split()))
aa = sorted(a)
s = aa[0] + aa[-1]
index = []
i = 0
while a:
	if a[i] == -1:
		i += 1
	else:
		to_find = s - a[i]
		ind = a.index(a[i])
		index.append(ind + 1)
		a[i] = -1
		ind2 = a.index(to_find)
		index.append(ind2 + 1)
		a[ind2] = -1
		i += 1
		if list(set(a))[0] == -1:
			break
for i in range(0, len(index), 2):
	print('{} {}'.format(index[i], index[i + 1]))


n = int(input())
A = input().split()
B = [0] * n
for i in range(len(A)):
	A[i] = int(A[i])
	B[i] = i
for i in range(n - 1):
	for j in range(i + 1, n):
		if A[i] > A[j]:
			t = A[i]
			A[i] = A[j]
			A[j] = t
			t = B[i]
			B[i] = B[j]
			B[j] = t
for i in range(n // 2):
	print(B[i] + 1, B[n - i - 1] + 1)


def main():
	n = int(input())
	nums = list(map(int, input().split()))
	cards = []
	for i in range(n):
		cards.append((nums[i], i + 1))
	cards = sorted(cards, key=lambda x: x[0])
	ans = []
	for i in range(int(n / 2)):
		ans.append((cards[i][1], cards[n - i - 1][1]))
	for i in ans:
		print(i[0], i[1])
main()


n = int(input())
l = list(map(int, input().split()))
s = int(sum(l) / n * 2)
tmp = list()
for i in range(n):
	a = l[i]
	l[i] = 0
	if a > 0:
		b = l.index(s - a)
		print(i + 1, l.index(s - a) + 1)
		l[l.index(s - a)] = 0


n = int(input())
li = list(map(int, input().split()))
valu = sum(li) // (n // 2)
for i in range(n):
	for j in range(n):
		if li[i] + li[j] == valu:
			if i == j:
				break
			print(i + 1, j + 1)
			li[i] = 0
			li[j] = 0
			break


n = int(input())
a = list(map(int, input().split()))
pair = n // 2
val = sum(a) // pair
for i in range(n):
	if a[i] != 0:
		x = a[i]
		a[i] = 0
		y = a.index(abs(val - x))
		print(i + 1, y + 1)
		a[y] = 0


n = int(input())
a = list(map(int, input().split()))
s = sum(a)
pair_sum = s / (n / 2)
mark = [None] * n
for i in range(n - 1):
	for j in range(i + 1, n):
		if mark[i] == None and a[i] + a[j] == pair_sum and (mark[j] == None):
			print(i + 1, end=' ')
			print(j + 1)
			mark[j] = 1
			mark[i] = 1


def cards(a, N):
	sum = 0
	b = a
	c = a[:]
	for item in a:
		sum = sum + item
	avg = sum / (N / 2)
	c = []
	for i in range(0, N):
		for j in range(i + 1, N):
			if a[i] + a[j] == avg and j not in c and (i not in c):
				print(i + 1, j + 1)
				c.append(j)
				break

def main():
	N = int(input())
	a = []
	s = input()
	for item in s.split(' '):
		a.append(int(item))
	cards(a, N)
main()


input()
a = list(map(int, input().split()))
num = sum(a) // (len(a) // 2)
i = 0
x = 1
arr = []
for g in range(0, len(a)):
	arr.append(1)
for i in range(0, len(a)):
	if arr[i] == 1:
		while x < len(a):
			if a[i] + a[x] == num and arr[x] == 1 and (i != x):
				print(i + 1, x + 1)
				arr[i] = 0
				arr[x] = 0
				x = len(a)
			else:
				x += 1
	x = 1


n = int(input())
seq = [int(j) for j in input().split(' ')]
k = sum(seq) / (n // 2)
results = []
first_index = 0
for i in range(n // 2):
	res = str(first_index + 1)
	first_number = seq[first_index]
	j = first_index + 1
	while seq[j] != k - first_number:
		j += 1
	res += ' ' + str(j + 1)
	(seq[first_index], seq[j]) = (0, 0)
	first_index += 1
	while seq[first_index] == 0 and i != n // 2 - 1:
		first_index += 1
	results.append(res)
for i in results:
	print(i)


n = int(input())
a = [int(i) for i in input().split()]
for i in range(n):
	a[i] = [a[i], i + 1]
a.sort()
l = 0
r = n - 1
while l < r:
	print(a[l][1], a[r][1])
	l += 1
	r -= 1


n = int(input())
ls = [int(i) for i in input().split()]
lscopy = ls.copy()
lscopy.sort()
i = 0
while i < n // 2:
	print(ls.index(lscopy[i]) + 1, end=' ')
	ls[ls.index(lscopy[i])] = -999
	print(ls.index(lscopy[n - i - 1]) + 1)
	ls[ls.index(lscopy[n - i - 1])] = -999
	i += 1


def main():
	n = int(input())
	cards = list(map(int, input().split()))
	total_sum = sum(cards)
	per_person_sum = int(total_sum * 2 / n)
	for i in range(n):
		if cards[i] != 0:
			for j in range(i + 1, n):
				if cards[i] + cards[j] == per_person_sum:
					print(i + 1, j + 1)
					cards[j] = 0
					break
main()


n = int(input())
A = list(map(int, input().split()))
A = sorted(range(len(A)), key=lambda k: A[k])
i = 0
j = len(A) - 1
while i < j:
	print(A[i] + 1, A[j] + 1)
	i += 1
	j -= 1


n = input()
s = list(map(int, input().split()))
sum = sum(s)
d = int(sum / (len(s) / 2))
f = []
for i in range(0, len(s)):
	if i not in f:
		f.append(i)
		for j in range(i + 1, len(s)):
			if d - s[i] == s[j] and j not in f:
				f.append(j)
				print(str(i + 1) + ' ' + str(j + 1))
				break


q = []

def findIndex(w, dic):
	index = -1
	while index == -1:
		for i in dic.keys():
			if dic[i] == w and i not in q:
				index = i
				q.append(i)
				break
	return index
input()
q = []
s = list(map(int, input().split()))
dic = {}
for i in range(len(s)):
	dic[i + 1] = s[i]
w = sorted(s)
ans = []
i = 0
j = len(s) - 1
while i <= j:
	index1 = findIndex(w[i], dic)
	index2 = findIndex(w[j], dic)
	ans.append([index1, index2])
	i += 1
	j -= 1
for i in ans:
	print(str(i[0]) + ' ' + str(i[1]))


n = int(input())
arr = list(map(int, input().split()))
used = list((False for x in range(n)))
sred = sum([x for x in arr]) * 2 // n
for i in range(n):
	for j in range(n):
		if i != j and arr[i] + arr[j] == sred and (used[i] != True) and (used[j] != True):
			print(i + 1, j + 1)
			used[i] = used[j] = True


n = int(input())
a = list(map(int, input().split(' ')))
t = [0] * n
split = int(sum(a) / (n / 2))
for _ in range(int(n / 2)):
	found = False
	for i in range(n):
		for j in range(i + 1, n):
			if t[i] == 0 and t[j] == 0:
				if a[i] + a[j] == split:
					print(i + 1, j + 1)
					t[i] = 1
					t[j] = 1
					found = True
					break
		if found is True:
			break


n = int(input())
z = list(map(int, input().split()))
y = int(sum(z) / n * 2)
count = 0
for i in range(n):
	if int(count) == n // 2:
		break
	elif z[i] == -1:
		continue
	else:
		print(i + 1, end=' ')
		temp = z[i]
		z[i] = -1
		x = z.index(abs(y - temp))
		print(x + 1)
		z[x] = -1
		count += 1


n = int(input())
a = list(map(int, input().split()))
x = max(a) + min(a)
used = list()
for i in range(n):
	for j in range(i, n):
		if j not in used and a[i] + a[j] == x and (j != i) and (i not in used):
			print(i + 1, j + 1)
			used.append(j)
			used.append(i)


n = int(input())
l = list(map(int, input().split()))
min1 = min(l) + max(l)
for i in range(n):
	for j in range(n):
		if l[i] + l[j] == min1 and i != j:
			print(i + 1, j + 1)
			l[i] = 0
			l[j] = 0


m = int(input())
a = list(map(int, input().split()))
k = sorted(range(1, m + 1), key=lambda z: a[z - 1])
[print(k[i], k[-i - 1]) for i in range(0, m // 2)]


def main():
	n = int(input())
	a = sorted(zip(map(int, input().split(' ')), range(1, n + 1)))
	for i in range(n // 2):
		print(a[i][1], a[-i - 1][1])
main()


n = int(input())
List = list(map(int, input().split(' ')))
numDict = {}
for (index, value) in enumerate(List):
	numDict[index] = value
numList = sorted(numDict.items(), key=lambda x: x[1])
for i in range(int(n / 2)):
	a = numList[i][0]
	b = numList[-(i + 1)][0]
	print(str(a + 1) + ' ' + str(b + 1))


def main():
	n = int(input())
	line = input()
	s = line.split()
	sum = 0
	for i in range(0, n):
		sum += int(s[i])
	sum /= n / 2
	for i in range(0, n):
		if s[i] != -1:
			for j in range(0, n):
				if int(s[i]) + int(s[j]) == sum and int(s[j]) != -1 and (i != j):
					s[i] = -1
					s[j] = -1
					print('{} {}'.format(i + 1, j + 1))
main()


n = int(input())
cards = list(map(int, input().split()))
s = min(cards) + max(cards)
for i in range(n):
	if cards[i] != 0:
		val = cards[i]
		cards[i] = 0
		pos = cards.index(s - val)
		cards[pos] = 0
		print(str(i + 1) + ' ' + str(pos + 1))


n = int(input())
l = list(map(int, input().split()))
x = sum(l) // (n // 2)
for i in range(n):
	if l[i] != 0:
		z = l[i]
		l[i] = 0
		print(i + 1, l.index(x - z) + 1)
		l[l.index(x - z)] = 0


def main():
	n = int(input()) // 2
	a = [int(i) for i in input().split()]
	import copy
	cp = copy.copy(a)
	cp.sort()
	(i, j) = (0, len(cp) - 1)
	while n != 0:
		im = a.index(cp[i])
		a[im] = None
		jm = a.index(cp[j])
		a[jm] = None
		print('{} {}'.format(im + 1, jm + 1))
		i += 1
		j -= 1
		n -= 1
main()


import sys

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

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

def input():
	return sys.stdin.readline().strip()
n = int(input())
arr = get_array()
ma = max(arr)
mi = min(arr)
s = ma + mi
check = [False] * n
for i in range(0, n):
	if check[i] == False:
		check[i] = True
		k = s - arr[i]
		for j in range(0, n):
			if k == arr[j] and i != j and (check[j] == False):
				check[j] = True
				print(1 + i, j + 1)
				break


n = int(input())
c = [int(i) for i in input().split()]
s = sum(c) // (n // 2)
for i in range(n):
	if c[i] != 0:
		b = c[i]
		c[i] = 0
		a = c.index(s - b)
		print(i + 1, a + 1)
		c[a] = 0


n = int(input())
sp = input().split()
for i in range(0, len(sp)):
	sp[i] = (sp[i], i + 1)
sp.sort(key=lambda x: int(x[0]))
for i in range(0, n // 2):
	print(int(sp[i][1]), int(sp[n - i - 1][1]))


n = int(input())
a = list(map(int, input().split()))
s = sum(a) // (n >> 1)
for k in range(n >> 1):
	for i in range(n - 1):
		for j in range(i + 1, n):
			if a[i] + a[j] == s:
				print(i + 1, j + 1)
				a[i] = -1000000
				a[j] = -1000000


n = int(input())
arr = list(map(int, input().split()))
avg = sum(arr) / n
x = [f - avg for f in arr]
c = n // 2
i = 0
while c > 0:
	if x[i] != '#':
		print(i + 1, x.index(-x[i], i + 1) + 1)
		x[x.index(-x[i], i + 1)] = '#'
		c -= 1
	i += 1


N = int(input())
A = list(map(int, input().split()))
sumv = sum(A) // (N // 2)
d = {}
for i in range(N):
	if A[i] in d:
		d[A[i]].append(i)
	else:
		d[A[i]] = [i]
for i in range(N):
	left = A[i]
	right = sumv - left
	if len(d[left]) == 0 or len(d[right]) == 0:
		continue
	left_ind = d[left][0]
	d[left] = d[left][1:]
	right_ind = d[right][0]
	d[right] = d[right][1:]
	print('{} {}'.format(left_ind + 1, right_ind + 1))


n = int(input())
l = list(map(int, input().split()))
ls = sorted(((l[i], i + 1) for i in range(n)))
ans = []
for i in range(n // 2):
	ans += [' '.join([str(ls[i][1]), str(ls[n - i - 1][1])])]
print('\n'.join(ans))


n = int(input().strip())
cards = list(map(int, input().strip().split()))
index = {}
for (idx, card) in enumerate(cards):
	index[card] = index.get(card, [])
	index[card].insert(0, idx + 1)
cards.sort()
for i in range(n // 2):
	print('%s %s' % (index[cards[i]].pop(), index[cards[n - i - 1]].pop()))


n = int(input())
a = list(map(int, input().split()))
indexes = list(range(n))
indexes.sort(key=a.__getitem__)
for i in range(n // 2):
	print(indexes[i] + 1, indexes[-i - 1] + 1)


n = int(input())
a = list(map(int, input().split()))
b = []
k = max(a)
l = min(a)
m = k + l
for i in range(n):
	if a[i] != 0:
		for j in range(i + 1, n):
			if a[i] + a[j] == m:
				c = [i + 1, j + 1]
				b.append(c)
				a[j] = 0
				break
			if len(b) == n // 2:
				break
for i in b:
	print(i[0], i[1])


(n, cards, total) = (input(), input().split(' '), 0)
for i in range(0, len(cards)):
	total += int(cards[i])
use = {}
average = total / int(n) * 2
for i in range(0, int(n)):
	target = int(average - int(cards[i]))
	for j in range(0, int(n)):
		if i != j and bool(use.get(i)) != True and (bool(use.get(j)) != True) and (int(cards[j]) == target):
			print(i + 1, j + 1)
			(use[i], use[j]) = (True, True)
			break


n = int(input())
cards = sorted([(y, x + 1) for (x, y) in enumerate(map(int, input().split()))])
half = len(cards) // 2
for ((a, ia), (b, ib)) in zip(cards[:half], reversed(cards[half:])):
	print(ia, ib)


import sys
from math import sqrt, floor, factorial
from collections import deque
inp = sys.stdin.readline
read = lambda : list(map(int, inp().strip().split()))

def solve():
	n = int(inp())
	ans = ''
	arr = sorted(zip(read(), range(n)))
	for i in range(n // 2):
		ans += str(arr[i][1] + 1) + ' ' + str(arr[n - i - 1][1] + 1) + '\n'
	print(ans)
solve()


n = int(input())
a = input().split()
x = 0
b = []
for i in range(n):
	a[i] = int(a[i])
	x += a[i]
	b += [i + 1]
x //= n // 2
z = 0
for i in range(n // 2):
	z = a[0]
	for j in range(1, n - 2 * i):
		if a[j] + z == x:
			print(b[0], b[j])
			c = j
			break
	a = a[1:c] + a[c + 1:]
	b = b[1:c] + b[c + 1:]


n = int(input())
ns = sorted(enumerate(map(int, input().split())), key=lambda x: x[1])
for i in range(n // 2):
	print(ns[i][0] + 1, ns[n - i - 1][0] + 1)


get_int = lambda : map(int, input().split())
n = int(input())
h = list(get_int())
pts = sum(h) * 2 / n
for i in h:
	if i != 0:
		a = h.index(i) + 1
		h[h.index(i)] = 0
		b = h.index(pts - i) + 1
		h[h.index(pts - i)] = 0
		print(a, b)


n = int(input())
card = list(map(int, input().split()))
sum = 0
for i in range(len(card)):
	sum += card[i]
per = sum * 2 // n
used = [False for i in range(len(card))]
for i in range(n // 2):
	ans = ''
	num = 0
	for j in range(len(card)):
		if used[j] == False:
			ans += str(j + 1)
			num = card[j]
			used[j] = True
			break
	for j in range(len(card)):
		if used[j] == False and per - num == card[j]:
			ans += ' ' + str(j + 1)
			used[j] = True
			break
	print(ans)


n = int(input())
a = list(map(int, input().split()))
b = sum(a) // (n // 2)
c = sorted(a)
d = [0 for i in range(n)]
for i in range(n // 2):
	x = b - c[i]
	for j in range(n):
		if a[j] == x and d[j] == 0:
			z = j
			d[j] = 1
			break
	for j in range(n):
		if a[j] == c[i] and d[j] == 0:
			y = j
			d[j] = 1
			break
	print(z + 1, y + 1)


n = int(input())
a = list(map(int, input().split()))
t = n // 2
b = []
(u, s) = (0, 0)
e = sum(a) // t
for i in range(n):
	for j in range(i + 1, n):
		if a[i] + a[j] == e:
			if i + 1 not in b:
				if j + 1 not in b:
					print(i + 1, j + 1)
					b.append(i + 1)
					b.append(j + 1)
					u += 1
					if u == t:
						s += 1
						break
	if s == 1:
		break


n = int(input())
a = list(map(int, input().split()))
b = []
S = sum(a) / (n / 2)
for i in range(n):
	for j in range(i + 1, n):
		if a[i] + a[j] == S and i not in b and (j not in b):
			print(i + 1, j + 1)
			b.extend((i, j))


n = int(input())
a = list(map(int, input().split()))
b = max(a) + min(a)
for i in range(n):
	for j in range(n):
		if a[i] + a[j] == b and i != j:
			print(i + 1, j + 1)
			a.remove(a[i])
			a.insert(i, 0)
			a.remove(a[j])
			a.insert(j, 0)


import operator as op
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import reduce
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

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

def instr():
	s = input()
	return list(s[:len(s)])

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

def def_value():
	return []
n = inp()
a = inlist()
get = sum(a) // (n // 2)
for i in range(n):
	for j in range(n):
		if i != j and a[i] + a[j] == get:
			print(i + 1, j + 1)
			a[i] = 0
			a[j] = 0


n = int(input())
a = input()
A = []
B = []
C = []
for i in a.split():
	A.append(int(i))
x = sum(A) / n * 2
z = 0
for i in range(0, n):
	if (i in C) == False:
		for j in range(i + 1, n):
			if A[i] + A[j] == x and (j in C) == False:
				B.append([i + 1, j + 1])
				C.append(j)
				break
for k in range(0, int(n / 2)):
	print(B[k][0], B[k][1])


n = int(input())
a = [(idx, int(val)) for (idx, val) in enumerate(input().split())]
a.sort(key=lambda x: x[1])
for i in range(n // 2):
	print(a[i][0] + 1, a[n - 1 - i][0] + 1)


n = int(input())
arr = input()
arr = arr.split(' ')
for i in range(n):
	arr[i] = int(arr[i])
temp = []
for i in range(n):
	temp.append(i + 1)
for i in range(n // 2):
	min_index = arr.index(min(arr))
	max_index = arr.index(max(arr))
	if arr[min_index] == arr[max_index]:
		c_1 = temp[max_index]
		del temp[max_index]
		del arr[max_index]
		c_2 = temp[min_index]
		del temp[min_index]
		del arr[min_index]
		print('{} {}'.format(c_1, c_2))
		continue
	print('{} {}'.format(temp[max_index], temp[min_index]))
	if max_index > min_index:
		del temp[max_index]
		del arr[max_index]
		del arr[min_index]
		del temp[min_index]
	else:
		del temp[min_index]
		del arr[min_index]
		del arr[max_index]
		del temp[max_index]


n = int(input())
a = list(map(int, input().split()))
total = sum(a)
target = 2 * total // n
for i in range(n):
	if a[i] is None:
		continue
	first = a[i]
	a[i] = None
	for j in range(i + 1, n):
		if a[j] is None:
			continue
		second = a[j]
		if first + second == target:
			a[j] = None
			break
	print(i + 1, j + 1)


n = int(input())
p = n // 2
cards = sorted([(i + 1, int(x)) for (i, x) in enumerate(input().split())], key=lambda x: x[1])
for x in range(p):
	print(cards[x][0], cards[n - x - 1][0])


def main():
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a) // (n // 2)
	for i in range(n):
		if a[i] != -1:
			(c, d) = (a[i], s - a[i])
			c = a.index(c)
			a[c] = -1
			d = a.index(d)
			a[d] = -1
			print(c + 1, d + 1)
main()


a = int(input())
b = list(map(int, input().split()))
o = sum(b) / (a / 2)
f = 1
v = []
for r in b:
	l = 1
	for k in b:
		if k + r == o:
			if r + k == o:
				if f not in v and l not in v and (l != f):
					v.append(f)
					v.append(l)
					break
		l = l + 1
	f = f + 1
for r in range(0, len(v), 2):
	print(str(v[r]) + ' ' + str(v[r + 1]))


import sys
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

def solve(n, a):
	som = sum(a) * 2 // n
	for _ in range(n // 2):
		i = 0
		while a[i] == 0:
			i += 1
		for j in range(1, n):
			if i != j and a[i] + a[j] == som:
				print(str(i + 1) + ' ' + str(j + 1))
				a[i] = 0
				a[j] = 0
				break

def output():
	n = inp()
	a = inlt()
	solve(n, a)
output()


cardCount = int(input())
cardListStr = input()
cardListStrs = cardListStr.split(' ')
cardList = [int(card) for card in cardListStrs]
cardSum = 0
for card in cardList:
	cardSum += card
cardAvg = cardSum / cardCount
playerSum = cardAvg * 2
result = {}
for i in range(cardCount):
	for j in range(cardCount):
		if i == j or result.get(j) != None or j in result.values():
			continue
		if cardList[i] + cardList[j] == playerSum:
			result[i] = j
			continue
for i in result.keys():
	print(i + 1, result[i] + 1, ' ')


n = int(input().strip())
ins = input().strip().split(' ')
a = []
for i in range(n):
	a.append((int(ins[i]), i + 1))
a.sort(key=lambda tup: tup[0])
for i in range(int(n / 2)):
	print(a[i][1], a[n - i - 1][1])


n = int(input())
m = list(map(int, input().split()))
g = n // 2
s = sum(m) // g
used = []
t = []
for i in range(n):
	for j in range(i + 1, n):
		if (i not in used and j not in used) and m[i] + m[j] == s:
			print(i + 1, j + 1)
			used.append(i)
			used.append(j)
			break


n = int(input())
cards = list(map(int, input().split()))
mid = sum(cards) // (n // 2)
used = []
for i in range(n - 1):
	for j in range(i + 1, n):
		if j not in used and i not in used and (cards[i] + cards[j] == mid):
			print(i + 1, j + 1)
			used.append(j)
			used.append(i)
			break


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_int = lambda : int(sys.stdin.readline().strip())
pt = lambda x: sys.stdout.write(str(x))
n = get_int()
lst = get_list()
s = 2 * sum(lst) // n
for i in range(n):
	for j in range(i + 1, n):
		if lst[i] + lst[j] == s:
			print(i + 1, j + 1)
			lst[i] = lst[j] = -101


n = int(input())
l = [int(y) for y in input().split()]
x = sum(l) // (n // 2)
l_copy = []
for i in range(n):
	l_copy.append(l[i])
visited = []
for i in range(n):
	visited.append(0)
for i in range(n):
	if visited[i] == 0:
		visited[i] = 1
		for j in range(n):
			if l_copy[j] == x - l[i] and i != j and (visited[j] == 0):
				if l[i] < l[j]:
					print(i + 1, j + 1)
				else:
					print(j + 1, i + 1)
				visited[j] = 1
				break


from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
n = int(input())
a = list(map(int, input().split(' ')))
s = sum(a) * 2 // n
used = []
for i in range(n):
	if i not in used:
		used.append(i)
		for j in range(i + 1, n):
			if j not in used:
				if a[i] + a[j] == s:
					used.append(j)
					print('{} {}'.format(i + 1, j + 1))
					break


dt = dict()
n = int(input())
nums = list(map(int, input().strip().split()))
for x in range(len(nums)):
	dt[x + 1] = nums[x]
ls = sorted(dt.values())
(st, ed) = (0, len(ls) - 1)
kk = list(dt.keys())
vv = list(dt.values())
for x in range(int(len(ls) / 2)):
	a1 = kk[vv.index(ls[st])]
	vv[vv.index(ls[st])] = -2
	a2 = kk[vv.index(ls[ed])]
	vv[vv.index(ls[ed])] = -2
	st += 1
	ed -= 1
	print(a1, a2)


n = int(input())
a = input()
a = a.split()
for i in range(n):
	a[i] = int(a[i])
minn = 101
maxx = 0
ans = []
for i in range(int(n / 2)):
	ans = ans + [-1, -1]
	minn = 101
	maxx = 0
	for j in range(n):
		if a[j] > maxx:
			maxx = a[j]
			ans[2 * i] = j
	a[ans[2 * i]] = int(-1)
	for j in range(n):
		if a[j] < minn and a[j] != -1:
			minn = a[j]
			ans[2 * i + 1] = j
	a[ans[2 * i + 1]] = int(-1)
for i in range(int(n / 2)):
	print(ans[2 * i] + 1, ' ', ans[2 * i + 1] + 1)


n = int(input())
l = list(map(int, input().split()))
ans = ''
h = max(l) + min(l)
for f1 in range(n - 1):
	for f2 in range(f1 + 1, n):
		if l[f1] + l[f2] == h:
			ans += str(f1 + 1) + ' ' + str(f2 + 1) + '\n'
			l[f1] = 0
			l[f2] = 0
			break
print(ans.strip())


n = int(input(''))
li = list(map(int, input().split()[:n]))
t = sum(li) // (n / 2)
l = len(li)
li1 = []
for i in range(l):
	for j in range(l):
		if i == j or i in li1 or j in li1:
			continue
		elif li[i] + li[j] == t:
			print(f'{i + 1} {j + 1}')
			li1.append(i)
			li1.append(j)


n = int(input())
a = list(map(int, input().split()))
t = list(zip(a, list(range(1, len(a) + 1))))
t.sort(key=lambda x: x[0])
for i in range(n // 2):
	print(t[i][1], t[-i - 1][1])


n = int(input())
l = list(map(int, input().split()))
ul = []
for i in range(1, n + 1):
	ul.append(i)
d = sorted(zip(l, ul))
l.sort()
for i in range(n // 2):
	print(d[i][1], d[-i - 1][1])


n = int(input())
cards = [int(i) for i in input().split()]
for j in range(n // 2):
	print(cards.index(min([j for j in cards if j != 0])) + 1, n - cards[::-1].index(max(cards)))
	cards[cards.index(min([j for j in cards if j != 0]))] = 0
	cards[n - cards[::-1].index(max(cards)) - 1] = 0


n = int(input())
card_num = [int(x) for x in input().split()]
sumofcards = sum(card_num)
avg = sumofcards / n * 2
for i in range(n):
	if card_num[i] != -1:
		for j in range(n):
			if card_num[i] + card_num[j] == avg and i != j and (card_num[i] != -1) and (card_num[j] != -1):
				print('{} {}'.format(i + 1, j + 1))
				card_num[i] = -1
				card_num[j] = -1
				break


from statistics import mean
n = int(input())
c = list(map(int, input().split()))
t = mean(c) * 2
for i in range(len(c)):
	if c[i] == 0:
		continue
	for j in range(len(c)):
		if i == j:
			continue
		if c[j] == 0:
			continue
		if c[i] + c[j] == t:
			print(i + 1, j + 1)
			c[i] = 0
			c[j] = 0


n = int(input())
v = n
N = n // 2
x = list(map(int, input().split()))
avg = sum(x) // N
for i in range(len(x)):
	for j in range(v):
		if sum([i + 1, j + 1]) > 0 and i != j:
			if x[i] + x[j] == avg:
				print(i + 1, j + 1)
				x[i] = 0
				x[j] = 0
				break


n = int(input())
l = list(map(int, input().split()))
l1 = []
for i in l:
	l1.append(i)
l1.sort()
isk = sum(l1) // (n // 2)
b = []
while len(l1) > 0:
	x = l1.pop()
	y = isk - x
	l1.remove(y)
	b.append(x)
	b.append(y)
d = []
for i in range(n):
	for j in range(len(l)):
		if b[i] == l[j]:
			if not j in d:
				d.append(j)
				break
while len(d) > 0:
	x = d.pop(0)
	y = d.pop(0)
	print(x + 1, y + 1)


import operator
n = int(input())
arr = [int(x) for x in input().split()]
d = {}
for i in range(n):
	d[i + 1] = arr[i]
dn = sorted(d.items(), key=operator.itemgetter(1))
for i in range(n // 2):
	print(dn[i][0], dn[n - i - 1][0])


n = int(input())
arr = list(map(int, input().split()))
val = 2 * sum(arr) // n
arr1 = [0] * n
i = 0
ansarr = []
while i < n:
	if arr1[i] == 0:
		for j in range(i + 1, n):
			if arr1[j] == 0:
				if arr[i] + arr[j] == val:
					print(i + 1, j + 1)
					arr1[i] = 1
					arr1[j] = 1
					break
	i += 1


N = int(input())
nums = [int(x) for x in input().split(' ')]
used = [False] * N
for i in range(N // 2):
	mxV = -1
	mxI = -1
	mnV = 10000000
	mnI = -1
	for j in range(N):
		if used[j]:
			continue
		if nums[j] > mxV:
			mxV = nums[j]
			mxI = j
	used[mxI] = True
	for j in range(N):
		if used[j]:
			continue
		if nums[j] < mnV:
			mnV = nums[j]
			mnI = j
	used[mnI] = True
	print(str(mxI + 1) + ' ' + str(mnI + 1))


def sort_key(a):
	return a[0]
n = int(input())
data = [int(i) for i in input().split()]
for i in range(n):
	data[i] = [data[i], i + 1]
data.sort(key=sort_key)
for i in range(n // 2):
	print(data[i][1], data[n - 1 - i][1])


n = int(input())
l = list(map(int, input().split()))
l1 = []
for i in range(1, n + 1):
	l1.append((i, l[i - 1]))
l1.sort(key=lambda l1: l1[1])
for i in range(n // 2):
	print(l1[i][0], l1[n - 1 - i][0])


import sys
ln = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
pair_sum = int(sum(arr) / (ln / 2))
visited_set = set()
for i in range(ln):
	if i in visited_set:
		continue
	visited_set.add(i)
	ind = arr.index(pair_sum - arr[i])
	while ind in visited_set:
		ind = ind + 1 + arr[ind + 1:].index(pair_sum - arr[i])
	visited_set.add(ind)
	print(i + 1, ind + 1)


n = int(input())
arr = [int(x) for x in input().split()]
s = min(arr) + max(arr)
for i in range(n):
	if arr[i] != -1:
		for j in range(i + 1, n):
			if arr[j] != -1:
				if arr[i] + arr[j] == s:
					print(i + 1, j + 1)
					(arr[i], arr[j]) = (-1, -1)


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


n = int(input())
arr = input()
arr = arr.split()
idx = []
for i in range(n):
	idx.append(i + 1)
for i in range(n):
	for j in range(n):
		if int(arr[i]) > int(arr[j]):
			(arr[i], arr[j]) = (arr[j], arr[i])
			(idx[i], idx[j]) = (idx[j], idx[i])
for i in range(n // 2):
	print(str(idx[i]) + ' ' + str(idx[n - i - 1]))


n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
	b.append(a[i])
b.sort()
b = b[::-1]
for i in range(n // 2):
	print(a.index(b[i]) + 1, end=' ')
	a[a.index(b[i])] = 0
	print(a.index(b[n - i - 1]) + 1)
	a[a.index(b[n - i - 1])] = 0


n = int(input())
t = map(int, input().split())
t = list(t)
li = []
for i in range(n):
	li += [[t[i], i + 1]]
li.sort()
for i in range(n // 2):
	print(li[i][1], li[n - i - 1][1])


n = int(input())
a = list(map(int, input().split()))
b = a.copy()
b.sort()
for i in range(int(n / 2)):
	cc = a.index(b[i]) + 1
	a[a.index(b[i])] = 0
	bb = a.index(b[-1]) + 1
	a[a.index(b[-1])] = 0
	b.remove(b[-1])
	print(cc, bb)


n = int(input())
string = input().split(' ')
for i in range(n):
	string[i] = int(string[i])
target = int(sum(string) / (n / 2))
result = []
for i in range(n):
	if not i in result:
		result.append(i)
		remaining = target - string[i]
		for j in range(n):
			if string[j] == remaining:
				if not j in result:
					result.append(j)
					break
for i in range(n // 2):
	stringToPrint = str(result[2 * i] + 1) + ' '
	stringToPrint += str(result[2 * i + 1] + 1)
	print(stringToPrint)


n = int(input())
x = list(map(int, input().split()))
y = [[x[i], i + 1] for i in range(len(x))]
y = sorted(y, key=lambda x: x[0])
while y != []:
	print(y.pop(0)[1], y.pop(-1)[1])


n = int(input())
a = list(map(int, input().split()))
for (i, j) in enumerate(a):
	a[i] = (i, j)
a = sorted(a, key=lambda x: x[1])
for i in range(n // 2):
	print(a[i][0] + 1, a[n - 1 - i][0] + 1)


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
n = ii1()
arr = iia()
a = []
for i in range(n):
	a.append([arr[i], i + 1])
a.sort()
for i in range(n // 2):
	print(a[i][1], a[-(i + 1)][1])


n = int(input())
t = list(map(int, input().split()))
minl = 1000000000
maxl = -1
for i in t:
	minl = min(minl, i)
	maxl = max(maxl, i)
add = minl + maxl
li = [[] for i in range(105)]
for i in range(n):
	if len(li[add - t[i]]) > 0:
		print(li[add - t[i]][-1], i + 1)
		li[add - t[i]].pop()
	else:
		li[t[i]].append(i + 1)


n = int(input())
list1 = list(map(int, input().split(' ')))
w = sum(list1) // (n >> 1)
for j in range(n):
	if list1[j] != None:
		q = list1[j]
		list1[j] = None
		p = list1.index(w - q) + 1
		print(j + 1, p)
		list1[p - 1] = None


n = int(input())
cards = list(map(int, input().split(' ')))
hand = min(cards) + max(cards)
found = {}
pairs = []
for i in range(n):
	if found.get(i, 0) == 1:
		continue
	for j in range(i + 1, n):
		if found.get(j, 0) == 1:
			continue
		if cards[i] + cards[j] == hand:
			found[i] = 1
			found[j] = 1
			pairs.append((i + 1, j + 1))
			break
for pair in pairs:
	print(str(pair[0]) + ' ' + str(pair[1]))


n = int(input())
l = list(map(int, input().split(' ')))
s = sum(l) / (n / 2)
used_index = []
for i in range(0, len(l) - 1):
	for j in range(i + 1, len(l)):
		if l[i] + l[j] == s and j not in used_index and (i not in used_index):
			print(i + 1, j + 1)
			used_index.append(j)
			break


n = int(input())
p = list(map(int, input().split()))
s = sum(p) // (n // 2)
w = []
for i in range(n):
	if p[i] != 0:
		for j in range(i + 1, n):
			if p[i] + p[j] == s:
				w.append((i + 1, j + 1))
				p[j] = 0
				break
		if len(w) == n // 2:
			break
for (i, j) in w:
	print(i, j, end=' ')
	print()


n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
while len(b) != 0:
	print(a.index(b[0]) + 1, end=' ')
	a[a.index(b[0])] = 101
	b.pop(0)
	print(a.index(b[-1]) + 1)
	a[a.index(b[-1])] = 101
	b.pop()


n = int(input())
spisok = list(map(lambda x: int(x), input().split(' ')))
sr = 2 * sum(spisok) // n
curr = 0
while curr < n:
	if spisok[curr] != 0:
		dpl = curr + 1
		while dpl < n:
			if spisok[curr] + spisok[dpl] == sr:
				print(1 + curr, 1 + dpl)
				break
			else:
				dpl += 1
		spisok[curr] = 0
		spisok[dpl] = 0
	curr += 1


n = int(input())
l = list(map(int, input().split()))
s = sum(l)
d = s // (n // 2)
c = 0
for i in range(n):
	if l[i] > 0:
		m = d - l[i]
		l[i] = l[i] * -1
		l1 = l.index(m)
		print(i + 1, l1 + 1)
		l[l1] = l[l1] * -1
		c += 1
	if c == n // 2:
		break


def check(lis, j):
	for yu in lis:
		if j == yu:
			return 0
	return 1
n = int(input())
li = list(map(int, input().split()))
su = int(sum(li) / (n / 2))
lis = []
i = 0
while len(li) > 0:
	j = len(li)
	while j > i:
		j = j - 1
		if li[i] + li[j] == su:
			if len(lis) == 0:
				lis.append(i + 1)
				lis.append(j + 1)
				break
			if check(lis, j + 1):
				lis.append(i + 1)
				lis.append(j + 1)
				break
	i = i + 1
	if len(lis) == n:
		break
for ig in range(0, n, 2):
	print(lis[ig], lis[ig + 1])


n = int(input())
a = list(map(int, input().split()))
b = [1 for i in range(n)]
s = sum(a)
t = s // (n // 2)
for i in range(n):
	for j in range(n):
		if i != j and b[i] and b[j] and (a[i] + a[j] == t):
			b[i] = b[j] = 0
			print(i + 1, j + 1)


n = int(input())
ans = 0
a = [(0, 0)] * n
lis = []
lis = input().split()
i = 0
while i < len(lis):
	a[i] = (int(lis[i]), i + 1)
	i += 1
a.sort()
i = 0
while i < len(a) / 2:
	print(a[i][1], a[n - i - 1][1])
	i += 1


n = int(input())
l = list(map(int, input().split()))
l1 = l[:]
for i in range(n // 2):
	d = min(l1)
	k = max(l1)
	print(l.index(d) + 1, end=' ')
	l[l.index(d)] = 0
	print(l.index(k) + 1)
	l[l.index(k)] = 0
	p1 = l1.index(d)
	l1 = l1[:p1] + l1[p1 + 1:]
	p2 = l1.index(k)
	l1 = l1[:p2] + l1[p2 + 1:]


n = int(input())
l = [int(i) for i in input().split()]
s = sum(l) // (n // 2)
for i in range(n):
	for j in range(i + 1, n):
		if l[i] + l[j] == s:
			l[i] = l[j] = 0
			print(i + 1, j + 1)
			break


n = int(input())
a = list(map(int, input().split()))
s = sum(a) // (n // 2)
used = [False for i in range(n)]
for i in range(n):
	if used[i]:
		continue
	used[i] = True
	for j in range(i + 1, n):
		if used[j]:
			continue
		if a[i] + a[j] == s:
			used[j] = True
			print(i + 1, j + 1)
			break


n = int(input())
vals = [int(i) for i in input().split()]
s = 2 * sum(vals) // n
for i in range(n):
	for j in range(i + 1, n):
		if vals[i] + vals[j] == s:
			print(i + 1, j + 1)
			vals[i] = 0
			vals[j] = 0


n = int(input())
a = [int(i) for i in input().split()]
b = [[0, 0]] + sorted(list(zip(a, [int(i) for i in range(1, n + 1)])))
for i in range(1, n // 2 + 1):
	print(b[i][1], b[n - i + 1][1])


n = int(input())
l = list(map(int, input().split()))
d = dict()
for i in range(1, n + 1):
	d[i] = l[i - 1]
d = dict(sorted(d.items(), key=lambda x: (x[1], x[0])))
(a, b) = (1, n)
g = []
g.append(0)
for x in d.keys():
	g.append(x)
for i in range(n // 2):
	print(g[a], g[b])
	a += 1
	b -= 1


n = int(input())
a = list(map(int, input().split()))
s = int(2 * sum(a) / n)
for i in range(n):
	if a[i] != -1:
		x = s - a[i]
		a[i] = -1
		print(i + 1, a.index(x) + 1)
		a[a.index(x)] = -1


n = int(input())
cards = [int(i) for i in input().split()]
solution = []
new_cards = sorted(cards)
for i in range(n // 2):
	a = new_cards[i]
	b = new_cards[n - i - 1]
	ai = cards.index(a)
	cards[ai] = None
	bi = cards.index(b)
	cards[bi] = None
	solution.append([ai + 1, bi + 1])
for x in solution:
	print(x[0], x[1])
	print()


n = int(input())
a = [int(x) for x in input().split()]
b = []
j = 1
for i in a:
	b.append((i, j))
	j += 1
b.sort()
j = 0
while j != n / 2:
	print(b[j][1], b[n - j - 1][1])
	j += 1


n = int(input())
a = list(map(int, input().split()))
target = sum(a) // (n // 2)
visited = [False] * n
for i in range(n):
	if not visited[i]:
		for j in range(i + 1, n):
			if not visited[j] and a[i] + a[j] == target:
				print(i + 1, j + 1)
				visited[i] = True
				visited[j] = True
				break


n = int(input())
a = list(map(int, input().split()))
tmp = sum(a) // (n // 2)
m = []
if n == 2:
	print(1, 2)
	exit()
for i in range(0, n):
	if i in m:
		continue
	else:
		for j in range(i + 1, n):
			if j in m:
				continue
			if a[i] + a[j] == tmp:
				print(i + 1, j + 1, sep=' ')
				m.append(i)
				m.append(j)
				break


k = int(input())
arr = list(map(int, input().split()))
i = 0
rez = sum(arr) / k * 2
zdez = {}
for i in range(k):
	if arr[i] not in zdez:
		zdez[arr[i]] = []
	zdez[arr[i]].append(i + 1)
for i in zdez:
	for j in zdez[i]:
		print(j, zdez[rez - i].pop())


import collections
n = int(input()) >> 1
M = collections.defaultdict(list)
s = 0
for (i, a) in enumerate(map(int, input().split())):
	M[a].append(1 + i)
	s += a
s //= n
for (a, d) in M.items():
	while d:
		n -= 1
		print(d.pop(), M[s - a].pop())
	if not n:
		break


input()
maps = {}
ar = list(map(int, input().split()))
each = sum(ar) // (len(ar) // 2)
for i in range(len(ar)):
	if ar[i] not in maps:
		maps[ar[i]] = [i + 1]
	else:
		maps[ar[i]] += [i + 1]
for m in maps:
	if maps[m]:
		if m != each - m:
			x1 = maps[m]
			x2 = maps[each - m]
			for i in range(len(x1)):
				print(str(x1[i]) + ' ' + str(x2[i]))
			maps[m] = []
			maps[each - m] = []
		else:
			for i in range(0, len(maps[m]), 2):
				print(str(maps[m][i]) + ' ' + str(maps[m][i + 1]))
			maps[m] = []


def print_pairs(numbers):
	target = sum(numbers) // (len(numbers) / 2)
	value_to_indices = {}
	for i in range(len(numbers)):
		if target - numbers[i] in value_to_indices and len(value_to_indices[target - numbers[i]]) > 0:
			index = value_to_indices[target - numbers[i]].pop()
			print(str(index + 1) + ' ' + str(i + 1))
		elif numbers[i] in value_to_indices:
			value_to_indices[numbers[i]].append(i)
		else:
			value_to_indices[numbers[i]] = [i]
n = int(input())
numbers = list(map(int, input().split()))
print_pairs(numbers)


import sys, math
n = int(input())
z = list(map(int, input().split()))
for i in range(n):
	z[i] = [z[i], i + 1]
z.sort()
for i in range(n // 2):
	print(z[i][1], z[n - 1 - i][1])


n = int(input())
l = list(map(int, input().split()))
(x, y, ans) = ([], [], [])
y.append(0)
y.append(0)
x.append(y)
y = []
for i in range(n):
	y.append(l[i])
	y.append(i + 1)
	x.append(y)
	y = []
x.sort()
for i in range(1, n // 2 + 1):
	y.append(x[i][1])
	y.append(x[-i][1])
	ans.append(y)
	y = []
for i in range(n // 2):
	print(*ans[i])


n = int(input())
A = list(map(int, input().split(' ')))
B = []
for i in range(n):
	k = [A[i], i + 1]
	B.append(k)
B.sort()
for i in range(n // 2):
	print(B[i][1], B[n - i - 1][1])


def main():
	n = int(input())
	values = list((int(_) for _ in input().split()))
	total = int(sum(values) / (n / 2))
	used = [False] * n
	for i in range(n):
		if not used[i]:
			used[i] = True
			for j in range(n):
				if not used[j] and values[i] + values[j] == total:
					used[j] = True
					print(i + 1, j + 1)
					break
main()


n = int(input())
l = list(map(int, input().split()))
s = sum(l) // (n // 2)
d = {}
for i in range(1, 101):
	d[i] = []
for (i, j) in enumerate(l):
	d[j].append(i + 1)
for i in range(1, 101):
	while len(d[i]) != 0:
		print(d[i][0], end=' ')
		d[i] = d[i][1:]
		print(d[s - i][0])
		d[s - i] = d[s - i][1:]


import sys
input = sys.stdin.readline()
n = int(input)
input = sys.stdin.readline()
arr = list(map(int, input.split()))
ar = []
for i in range(n):
	ar.append([arr[i], i + 1])
ar.sort()
for i in range(n // 2):
	print(ar[i][1], ar[n - 1 - i][1])


n = int(input())
arr = list(map(int, input().split()))
arr2 = sorted(arr, reverse=True)
p1 = []
p2 = []
for i in range(n // 2):
	ind = arr.index(arr2[i])
	p1.append(ind + 1)
	arr[ind] = 0
arr2.reverse()
for i in range(n // 2):
	ind = arr.index(arr2[i])
	p2.append(ind + 1)
	arr[ind] = 0
for i in range(n // 2):
	print(p1[i], p2[i])


n = int(input())
l = input().split()
for i in range(len(l)):
	l[i] = int(l[i])
for j in range(n // 2):
	indexerk = 0
	indexerb = 0
	k = 120
	b = 0
	for i in range(len(l)):
		if l[i] < k and l[i] != -1:
			k = l[i]
			indexerk = i
		if l[i] >= b and l[i] != -1:
			b = l[i]
			indexerb = i
	print(indexerk + 1, indexerb + 1)
	l[indexerk] = -1
	l[indexerb] = -1


N = int(input())
A = list(map(int, input().split()))
sum = 0
for a in A:
	sum += a
for i in range(N):
	for j in range(N):
		if i != j and A[i] + A[j] == sum / N * 2:
			print(i + 1, j + 1)
			A[i] = 0
			A[j] = 0


n = int(input())
a = list(map(int, input().split()))
b = []
for i in a:
	b.append(i)
a.sort()
c = []
while len(a) != 0:
	x = b.index(a[0])
	b[b.index(a[0])] = 0
	y = b.index(a[len(a) - 1])
	b[b.index(a[len(a) - 1])] = 0
	c.append([1 + x, 1 + y])
	del a[0]
	del a[len(a) - 1]
for i in range(len(c)):
	print(c[i][0], c[i][1])


n = int(input())
a = list(map(int, input().split()))
s = 2 * sum(a) // n
ii = []
for i in range(n):
	if not i in ii:
		for j in range(i + 1, n):
			if not j in ii and a[i] + a[j] == s:
				print(i + 1, j + 1)
				ii.append(i)
				ii.append(j)
				break


num_cards = int(input())
half = int(num_cards / 2)
cards = list(enumerate([int(x) for x in input().split(' ')]))
sort_cards = sorted(cards, key=lambda x: x[1])
for i in range(half):
	print(sort_cards[i][0] + 1, sort_cards[num_cards - i - 1][0] + 1)


n = int(input().strip())
ll = list(map(int, input().split()))
indeks = []
summ = sum(ll) // (n // 2)
for i in range(n):
	if i not in indeks:
		indeks.append(i)
		k = summ - ll[i]
		for j in range(n):
			if ll[j] == k and j not in indeks:
				print(i + 1, j + 1)
				indeks.append(j)
				break


n = int(input())
arr = list(map(int, input().split(' ')))
l = []
for i in range(n):
	l.append([i + 1, arr[i]])
l = sorted(l, key=lambda x: x[1])
for i in range(n // 2):
	print(str(l[i][0]) + ' ' + str(l[n - i - 1][0]))


n = int(input())
inp = sorted([(j, i) for (i, j) in enumerate(map(int, input().split()), 1)])
i = 0
while i < int(n / 2):
	print(inp[i][1], inp[n - i - 1][1])
	i += 1


n = int(input())
a = list(map(int, input().split()))
b = [0] * n
k = sum(a) / n * 2
for j in range(len(a)):
	for i in range(j + 1, len(a)):
		if a[j] + a[i] == k and b[j] == 0 and (b[i] == 0):
			print(j + 1, i + 1)
			b[j] = 1
			b[i] = 1
			break


n = int(input())
a = [int(x) for x in input().split()]
b = sum(a) * 2 // n
for i in range(n):
	if a[i] != -100:
		c = a.index(b - a[i], i + 1)
		print(i + 1, c + 1)
		a[i] = -100
		a[c] = -100


n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
for i in range(n // 2):
	p = a.index(b[i])
	a[p] = -1
	q = a.index(b[n - i - 1])
	a[q] = -1
	print(p + 1, q + 1)


n = int(input())
a = list(map(int, input().split()))
b = 0
a = sorted([(int(a[i]), i + 1) for i in range(n)])
for i in range(0, len(a) // 2):
	print(a[i][1], a[-i - 1][1])


cards = int(input())
reach = 0
card = 0
ans = []
ansint = []
cardind = 0
data = list(map(int, input().split()))
add = sum(data) / (cards / 2)
for cardind in range(int(len(data)) - 1):
	if data[cardind] == -1:
		continue
	card = data[cardind]
	reach = abs(card - add)
	ansint.append(data[int(cardind)])
	ansint.append(int(reach))
	data[cardind] = -1
	ans.append(cardind + 1)
	ans.append(data.index(int(reach)) + 1)
	data[data.index(int(reach))] = -1
for i in range(0, int(len(data)), 2):
	print(ans[i], end=' ')
	print(ans[i + 1])


n = int(input())
lst = [int(x) for x in input().split()]
used = [False] * n
needed = sum(lst) // (n // 2)
answer = []
for (i, x) in enumerate(lst):
	if used[i]:
		continue
	for (j, y) in enumerate(lst):
		if used[j] or i == j:
			continue
		if x + y == needed:
			answer.append((i + 1, j + 1))
			(used[i], used[j]) = (True, True)
			break
print('\n'.join(('{0} {1}'.format(*line) for line in answer)))


n = int(input())
array = list(map(int, input().split()))
a = [0] * n
i = 0
while i < n:
	a[i] = i
	i += 1
i = 0
while i < n - 1:
	for j in range(n - i - 1):
		if array[j] > array[j + 1]:
			(array[j], array[j + 1]) = (array[j + 1], array[j])
			(a[j], a[j + 1]) = (a[j + 1], a[j])
	i += 1
i = 0
while i < int(n / 2):
	print(a[i] + 1, a[n - i - 1] + 1)
	i += 1


n = int(input())
a = list(map(int, input().split()))
v = [(a[i], i + 1) for i in range(n)]
v.sort()
for i in range(n // 2):
	print(v[i][1], v[n - i - 1][1])


n = int(input())
a = list(map(int, input().split(' ')))
b = [{'index': 0, 'value': 0}] * n
for i in range(n):
	b[i] = {'index': i + 1, 'value': a[i]}
b.sort(key=lambda k: k['value'])
for i in range(n // 2):
	print(b[i]['index'], b[n - i - 1]['index'])


n = int(input())
cards = [int(x) for x in input().split()]
average = int(sum(cards) / (n / 2))
for i in range(0, n):
	if cards[i] != 0:
		print(i + 1, end=' ')
		for j in range(i + 1, n):
			if cards[j] == average - cards[i]:
				print(j + 1)
				cards[j] = 0
				break
		cards[i] = 0


n = int(input())
ls = list(map(int, input().split()))
m = sum(ls) // (n // 2)
for i in range(n):
	if ls[i] == -1:
		continue
	for j in range(i + 1, n):
		if ls[i] + ls[j] == m:
			print(i + 1, j + 1)
			ls[i] = ls[j] = -1
			break


n = int(input())
s = input()
a = s.split()
for i in range(len(a)):
	a[i] = int(a[i])
su = int(sum(a) / int(n / 2))
i = 0
while i < len(a):
	j = 1
	while j < len(a):
		if j == i:
			j += 1
		if j == len(a):
			break
		if a[i] + a[j] == su:
			print(i + 1, j + 1)
			a[i] = 0
			a[j] = 0
		else:
			j += 1
	i += 1


n = int(input())
cards = list(map(int, input().split()))
a = []
for i in range(n):
	a.append([cards[i], i])
a.sort(key=lambda x: x[0])
for i in range(n // 2):
	(x, y) = (a[i][1], a[n - i - 1][1])
	print(str(x + 1) + ' ' + str(y + 1))


n = int(input())
a = [int(i) for i in input().split()]
sum = 0
for item in a:
	sum += item
i = 0
j = 0
while a != [0] * n:
	if a[i] == 0:
		i += 1
	if a[j + 1] == 0:
		j += 1
	if j + 1 == n:
		j = -1
	if i != j + 1 and a[i] + a[j + 1] == sum / (n / 2):
		print(i + 1, j + 2)
		a[i] = 0
		a[j + 1] = 0
		i += 1
		j = -2
	j += 1


n = int(input())
cards = [int(i) for i in input().split()]
cards2 = []
for i in cards:
	cards2.append(i)
cards2.sort()
for i in range(n // 2):
	ans = ''
	ans += str(cards.index(cards2[i]) + 1)
	cards[cards.index(cards2[i])] = 0
	ans += ' ' + str(cards.index(cards2[n - i - 1]) + 1)
	cards[cards.index(cards2[n - i - 1])] = 0
	print(ans)


n = int(input())
lis = [int(x) for x in input().split(' ')]
lis1 = sorted(lis)
j = 0
for i in range(n // 2):
	x = lis.index(lis1[j])
	lis[x] = 0
	print(x + 1, end=' ')
	x = lis.index(lis1[n - 1 - j])
	lis[x] = 0
	print(x + 1, end=' ')
	j = j + 1
	print()


a = int(input())
n = [int(i) for i in input().split()][:a]
r = sum(n)
y = a / 2
t = r / y
for l in range(len(n)):
	if n[l] > 0:
		for k in range(l + 1, len(n) + 1):
			if n[l] + n[k] == t:
				n[l] = 0
				n[k] = 0
				print(f'{l + 1} {k + 1}')
				break


cards = int(input())
b = [int(x) for x in input().split()]
c = []
for i in range(0, len(b)):
	lowIndex = b.index(min(b))
	b[lowIndex] = 9999
	c.append(lowIndex)
for i in range(0, int(len(b) / 2)):
	print(c[i] + 1, ' ', c[len(c) - (i + 1)] + 1)


n = int(input())
n2 = n // 2
arr = [int(x) for x in input().split()]
che = [0 for i in range(n)]
sum = sum(arr)
di = sum // n2
for i in range(n):
	if che[i] == 0:
		che[i] = 1
		s = str(i + 1)
		k = di - arr[i]
		for j in range(i + 1, n):
			if che[j] == 0:
				if arr[j] == k:
					che[j] = 1
					print(s + ' ' + str(j + 1))
					break


n = int(input())
numbers = [int(i) for i in input().split()]
indexes = sorted(range(1, n + 1), key=lambda i: numbers[i - 1])
for i in range(n // 2):
	print(indexes[i], indexes.pop())


n = int(input())
A = [*zip(map(int, input().split()), range(1, n + 1))]
A.sort(key=lambda x: x[0])
(i, j) = (0, len(A) - 1)
while i < j:
	print(A[i][1], A[j][1])
	i += 1
	j -= 1


cards = []
n = int(input())
a = list(map(int, input().split()))
s = sum(a) // (n // 2)
for person in range(n // 2):
	firstCard = 0
	index1 = 0
	index2 = 0
	for card in range(n - 1, -1, -1):
		if a[card] != 0 and firstCard == 0:
			firstCard = a[card]
			index1 = card + 1
			a[card] = 0
		elif a[card] != 0:
			if firstCard + a[card] == s:
				index2 = card + 1
				a[card] = 0
				break
	cards.append([index1, index2])
for pair in cards:
	print(' '.join((str(num) for num in pair)))


__author__ = 'Alexander'
import sys
n = int(sys.stdin.readline())
kart = list(map(int, sys.stdin.readline().split()))
sum = sum(kart)
each = int(sum * 2 / n)
for i in range(n):
	if kart[i] != -1:
		a = kart[i]
		kart[i] = -1
		j = kart.index(each - a)
		sys.stdout.write(str(i + 1) + ' ' + str(j + 1) + '\n')
		kart[j] = -1
	else:
		continue


n = int(input())
lst = list(map(int, input().split()))
d = []
for i in range(n):
	d.append((lst[i], i + 1))
d.sort()
for i in range(n // 2):
	print(d[i][1], d[n - i - 1][1])


n = int(input())
vec = list(map(int, input().split()))
ans = list()
for i in range(n):
	tmp_list = list()
	tmp_list.append(vec[i])
	tmp_list.append(i + 1)
	ans.append(tmp_list)
ans = sorted(ans)
for i in range(n // 2):
	print(ans[i][1], ans[-(i + 1)][1])


N = int(input())
L = list(map(int, input().split()))
y = sum(L)
y = int(y / (N / 2))
for i in range(N):
	for j in range(i + 1, N):
		if L[i] + L[j] == y:
			L[i] = -10000
			L[j] = -10000
			print(i + 1, j + 1)
			break


n = int(input())
l = list(map(int, input().split()))
value = int(sum(l) / (n / 2))
for i in range(n):
	if l[i] != -1:
		j = l[i]
		l[i] = -1
		print(str(i + 1) + ' ' + str(l.index(value - j) + 1))
		l[l.index(value - j)] = -1


n = int(input())
cards = list(map(int, input().split()))
half = sum(cards) * 2 // n
for i in range(n - 1):
	for j in range(i + 1, n):
		if cards[i] + cards[j] == half:
			print(i + 1, j + 1)
			cards[i] = cards[j] = 0


n = int(input())
l = list(map(int, input().split()))
s = int(sum(l) / (n / 2))
d = []
for i in range(n):
	if l[i] < 0:
		continue
	for j in range(n):
		if l[j] < 0:
			continue
		if l[i] + l[j] == s and i != j:
			d.append((i + 1, j + 1))
			l.pop(i)
			l.insert(i, -100)
			l.pop(j)
			l.insert(j, -100)
			break
for i in d:
	print(*i)


n = int(input())
a = list(enumerate(map(int, input().split())))
a.sort(key=lambda x: x[1])
for i in range(n // 2):
	p = a[i]
	q = a[-i - 1]
	print(p[0] + 1, q[0] + 1)


n = int(input())
l = list(map(int, input().split()))
m = max(l) + min(l)
a = []
for i in range(n):
	if l[i] != 0:
		for j in range(i + 1, n):
			if l[i] + l[j] == m:
				a.append(i + 1)
				a.append(j + 1)
				l[i] = 0
				l[j] = 0
for i in range(0, n, 2):
	print(a[i], a[i + 1])


n = int(input())
l = list(map(int, input().split()))
a = sorted(l)
for i in range(n // 2):
	c = l.index(a[i])
	l[c] = -1
	d = l.index(a[n - 1 - i])
	l[d] = -1
	print(c + 1, d + 1)


from collections import defaultdict, Counter

def solve(arr, n):
	d = defaultdict(list)
	c = Counter(arr)
	st = set()
	for (index, value) in enumerate(arr):
		d[value].append(index + 1)
	m = 2 * sum(arr) // n
	for x in arr:
		if c[x]:
			if x == m - x:
				print(d[x][-1], end=' ')
				print(d[m - x][-2])
			else:
				print(d[x][-1], d[m - x][-1])
			d[x].pop()
			d[m - x].pop()
			c[x] -= 1
			c[m - x] -= 1
n = int(input())
arr = list(map(int, input().split()))
solve(arr, n)


n = int(input())
ip = list(map(int, input().split()))
ip2 = []
for i in range(n):
	ip2.append((i, ip[i]))
ip2 = sorted(ip2, key=lambda x: x[1])
for i in range(n // 2):
	print(ip2[i][0] + 1, ip2[n - i - 1][0] + 1)


n = int(input())
a = list(map(int, input().split()))
summ = sum(a) // (n // 2)
array = []
for i in range(n):
	for j in range(n):
		if i != j and a[i] + a[j] == summ and (i not in array) and (j not in array):
			array.append(i)
			array.append(j)
			print(i + 1, j + 1)
			break


n = int(input())
ar = list(map(int, input().split()))
t = max(ar) + min(ar)
for i in range(len(ar) - 1):
	for j in range(i + 1, len(ar)):
		if ar[i] + ar[j] == t:
			print(i + 1, j + 1)
			ar[i] = 0
			ar[j] = 0


n = int(input())
a = [int(x) for x in input().split()]
a2 = [int(x) for x in range(1, n + 1)]
new_a = list(map(lambda x, y: (x, y), a, a2))
new_a.sort()
for i in range(n // 2):
	print(new_a[i][1], new_a[n - 1 - i][1], sep=' ')


n = int(input())
a = [int(x) for x in input().split()]
b = [[a[i], i] for i in range(n)]
b.sort()
for i in range(n // 2):
	print(b[i][1] + 1, b[n - i - 1][1] + 1)


n = int(input())
L = [int(x) for x in input().split()]
A = [0] * 101
d = {}
for j in range(n):
	i = L[j]
	A[i] += 1
	if i not in d:
		d[i] = []
	d[i].append(j)
req = 2 * sum(L) // n
for i in range(101):
	while A[i]:
		print(d[i].pop() + 1, d[req - i].pop() + 1)
		A[i] -= 1
		A[req - i] -= 1


n = int(input())
a = list(map(int, input().split()))
a = list(enumerate(a))
a.sort(reverse=True, key=lambda x: x[1])
for i in range(n // 2):
	print(a[i][0] + 1, a[n - i - 1][0] + 1)


n = int(input())
a = input()
arr1 = a.split()
arr = []
avg = 0
for i in arr1:
	arr.append(int(i))
	avg += int(i)
ppl = n // 2
avg = avg // ppl
dicts = {}
counts = {}
index = 0
for i in arr:
	index += 1
	if i not in dicts:
		dicts[i] = []
		dicts[i].append(index)
		counts[i] = []
		counts[i].append(index)
	else:
		dicts[i].append(index)
		counts[i].append(index)
ans = []
for (key, value) in dicts.items():
	arrt = counts[key]
	if len(arrt) == 0:
		continue
	diff = avg - key
	ar = len(counts[key])
	at = counts[key]
	while ar > 0:
		diff = avg - key
		if diff == key:
			g = at[0]
			ty = at[1]
			ans.append((g, ty))
			at = at[2:]
			ar = len(at)
		else:
			g = at[0]
			at = at[1:]
			ar = len(at)
			ty1 = counts[diff]
			ty = ty1[0]
			counts[diff] = ty1[1:]
			ans.append((g, ty))
strs = ''
for i in ans:
	strs += str(i[0]) + ' ' + str(i[1])
	print(strs)
	strs = ''


n = int(input())
a = list(map(int, input().split()))
s = sum(a) // (n // 2)
dic = {}
for i in range(n):
	if not a[i] in dic.keys():
		dic[a[i]] = list()
	dic[a[i]].append(i)
for (key, val) in dic.items():
	while len(val) != 0:
		a = val.pop()
		b = dic[s - key].pop()
		print(a + 1, b + 1)


import sys
import math
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
n = inp()
li = inlt()
li2 = li.copy()
li2.sort()
ans = li2[0] + li2[n - 1]
for i in range(len(li)):
	for j in range(i + 1, len(li)):
		if li[i] + li[j] == ans:
			print(i + 1, j + 1)
			li[j] = ans + 10000
			break


from sys import stdin
n = int(input())
cartes = list(map(int, stdin.readline().split()))
indiceCarte = [[] for loop in range(n)]
for i in range(n):
	indiceCarte[i] = [cartes[i], i]
indiceCarte.sort()
for i in range(n // 2):
	inf = i
	sup = n - i - 1
	print(indiceCarte[inf][1] + 1, indiceCarte[sup][1] + 1)


n = int(input())
x = list(map(int, input().split()))
s = sum(x)
k = set()
for i in range(n):
	for j in range(i + 1, n):
		if x[i] + x[j] == s // (n // 2):
			if i in k or j in k:
				continue
			else:
				k.add(i)
				k.add(j)
				print(i + 1, j + 1)


n = int(input())
a = [int(x) for x in input().split()]
b = sorted(a)
j = -1
for i in range(len(a) // 2):
	k = a.index(b[i]) + 1
	a[a.index(b[i])] = 0
	l = a.index(b[j]) + 1
	a[a.index(b[j])] = 0
	j -= 1
	print(k, l)


n = int(input())
li = [int(x) for x in input().split()]
ans = [True for x in range(n)]
sum = 0
for x in range(n):
	sum += li[x]
sum //= n // 2
for x in range(n):
	for y in range(x + 1, n):
		if li[x] + li[y] == sum and ans[x] and ans[y]:
			print(x + 1, y + 1)
			ans[x] = False
			ans[y] = False


n = int(input())
arr = input().split()
arr = list(map(int, arr))
s = 0
for i in arr:
	s = s + i
s = 2 * s
s = s // n
hsh = []
for i in range(n):
	hsh.append(1)
for i in range(n):
	if hsh[i] == 1:
		for j in range(n):
			if hsh[j] == 1 and i != j:
				if arr[i] + arr[j] == s:
					print(str(i + 1) + ' ' + str(j + 1))
					hsh[i] = 0
					hsh[j] = 0
					break


n = int(input())
a = list(map(int, input().split()))
r = []
s = sum(a) // (n // 2)
for i in range(0, n):
	r.append(False)
for i in range(0, n - 1):
	if r[i] == False:
		for j in range(i + 1, n):
			if a[i] + a[j] == s and r[j] == False:
				print(i + 1, j + 1)
				r[j] = True
				break


n = int(input())
ma = 0
mi = 101
s = list(map(int, input().split()))
for i in range(n):
	if s[i] < mi:
		mi = s[i]
	if s[i] > ma:
		ma = s[i]
	s[i] = (s[i], i + 1)
su = mi + ma
s = sorted(s)
for i in range(len(s) // 2):
	print(s[i][1], s[len(s) - i - 1][1])


n = int(input())
cards = [int(x) for x in input().split(' ')]
pos = [i for i in range(1, n + 1)]
mini = 200
switch = True
while switch == True:
	switch = False
	for i in range(1, n):
		if cards[i - 1] > cards[i]:
			temp = cards[i]
			temp2 = pos[i]
			cards[i] = cards[i - 1]
			pos[i] = pos[i - 1]
			cards[i - 1] = temp
			pos[i - 1] = temp2
			switch = True
superior = n - 1
for i in range(n // 2):
	print(str(pos[i]) + ' ' + str(pos[superior]))
	superior -= 1


n = int(input())
a = [int(x) for x in input().split()]
pair = []
ne = max(a) + min(a)
for i in range(n):
	for ii in range(i + 1, n):
		if a[i] != 0 and a[ii] != 0 and (a[i] + a[ii] == ne):
			pair.append([i + 1, ii + 1])
			a[i] = 0
			a[ii] = 0
for i in pair:
	print(*i)


import operator
n = int(input())
a = [int(s) for s in input().split(' ')]
asorted = sorted(enumerate(a), key=operator.itemgetter(1))
for i in range(n // 2):
	print(asorted[i][0] + 1, asorted[n - 1 - i][0] + 1)


n = int(input())
arr = [int(x) for x in input().split()]
t = zip(arr, range(1, n + 1))
t = sorted(t)
for i in range(len(t) // 2):
	print(t[i][1], t[n - i - 1][1])


n = int(input())
arr = [int(i) for i in input().split(' ')]
sum = sum(arr) // (n // 2)
vis = [int(0) for i in range(int(100.0 + 5))]
for i in range(n):
	for j in range(n):
		if arr[i] + arr[j] == sum and i != j and (vis[i] | vis[j] == False):
			print(i + 1, j + 1)
			vis[i] = vis[j] = True


n = int(input())
arr = [int(i) for i in input().split()]
for i in range(n):
	arr[i] = (arr[i], i + 1)
arr.sort(key=lambda x: x[0])
for i in range(n // 2):
	print(arr[i][1], arr[n - i - 1][1])


n = int(input())
l = list(map(int, input().split()))
avg = sum(l) // (n // 2)
ok = [True for i in range(n + 1)]
for i in range(n):
	if not ok[i]:
		continue
	ok[i] = False
	for j in range(n):
		if ok[j] and l[i] + l[j] == avg:
			ok[j] = False
			print(i + 1, j + 1)
			break


n = int(input())
c = list(map(int, input().split()))
s = sorted(c)
match = 0
l = []
p = n // 2
for i in range(p):
	n -= 1
	a = c.index(s[i])
	c[a] = -1
	b = c.index(s[n])
	c[b] = -1
	print(a + 1, ' ', b + 1)


from sys import stdin
from collections import defaultdict
n = int(stdin.readline())
nums = list(map(int, stdin.readline().rstrip().split(' ')))
s = 0
locations = defaultdict(list)
for (i, num) in enumerate(nums):
	locations[num].append(i + 1)
	s += num
t = s // (n // 2)
v = set()
for (i, num) in enumerate(nums):
	if i + 1 not in v:
		p = locations[t - num].pop()
		v.add(i + 1)
		v.add(p)
		print('{} {}'.format(i + 1, p))


n = int(input())
cards = [int(i) for i in input().split()]
flag = [False for i in range(n)]
val = 2 * sum(cards) // n
for i in range(n):
	if not flag[i]:
		for j in range(i + 1, n):
			if not flag[j] and cards[i] + cards[j] == val:
				print(i + 1, j + 1)
				(flag[i], flag[j]) = (True, True)
				break


n = int(input())
a = [int(i) for i in input().split()]
for i in range(n):
	a[i] = (a[i], i + 1)
a = sorted(a)
for i in range(n // 2):
	print(a[i][1], a[n - 1 - i][1])


n = int(input())
l = [int(x) for x in input().split()]
v = sum(l) * 2 // n
was = []
for i in range(n):
	if not i in was:
		tmp = v - l[i]
		for j in range(i + 1, n):
			if l[j] == tmp and (not j in was):
				was.append(j)
				print(i + 1, j + 1)
				break


import sys
n = int(input())
a = [int(i) for i in input().split(' ')]
norm = int(2 * sum(a) / n)
for i in range(n):
	if a[i] != 0:
		for j in range(n):
			if a[i] + a[j] == norm and i != j:
				print(i + 1, j + 1)
				a[i] = 0
				a[j] = 0
				break


n = int(input())
mas = list(map(int, input().split()))
s = sum(mas) / (n / 2)
mmi = []
mmj = []
for i in range(n):
	for j in range(n):
		if i != j and mas[i] + mas[j] == s:
			c = 0
			for k in range(len(mmi)):
				if j == mmj[k] or i == mmi[k] or j == mmi[k] or (i == mmj[k]):
					c = 1
					break
			if c == 0:
				print(i + 1, j + 1)
				mmi.append(i)
				mmj.append(j)
				break


n = int(input())
t = list(map(int, input().split()))
list = []
for i in range(n):
	list.append((i + 1, t[i]))
list.sort(key=lambda x: x[1])
for i in range(n // 2):
	print(list[i][0], list[-i - 1][0])


n = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(n)]
s = sum(a) // (n // 2)
j = 0
for i in range(n // 2):
	found1 = False
	found2 = False
	hulp = []
	j = 0
	while found1 == False:
		if b[j] == 0:
			found1 = True
			b[j] = 1
			hulp.append(str(j + 1))
			j += 1
		else:
			j += 1
	while found2 == False:
		if b[j] == 0 and a[int(hulp[0]) - 1] + a[j] == s:
			found2 = True
			b[j] = 1
			hulp.append(str(j + 1))
			j += 1
		else:
			j += 1
	print(' '.join(hulp))


n = int(input())
c = list(map(int, input().split()))
k = min(c) + max(c)
for i in range(n):
	if c[i] != 0:
		for j in range(i + 1, n):
			if c[i] + c[j] == k:
				c[i] = 0
				c[j] = 0
				print(i + 1, j + 1)
				break


n = int(input())
l = [int(i) for i in input().split()]
for i in range(n // 2):
	mn = max(l)
	an = l.index(mn)
	for i in range(n):
		if l[i] < mn and l[i] != -1:
			mn = l[i]
			an = i
	l[an] = -1
	mx = max(l)
	ax = l.index(mx)
	print(an + 1, ax + 1)
	l[ax] = -1


n = int(input())
a = list(map(int, input().split()))
d = []
for i in range(n):
	d.append((a[i], i + 1))
d.sort()
for j in range(n // 2):
	print(d[j][1], d[-1 - j][1], sep=' ')


cards = int(input())
cv = [int(x) for x in input().split()]
minmax = min(cv) + max(cv)
for x in range(cards):
	if cv[x] != 0:
		a = cv.index(cv[x])
		b = cv.index(minmax - cv[x])
		if a != b:
			print(a + 1, b + 1)
			cv[a] = 0
			cv[b] = 0
		else:
			i = 1
			while cv[a] != cv[b + i]:
				i += 1
			print(a + 1, b + i + 1)
			cv[a] = 0
			cv[b + i] = 0


import sys
input = lambda : sys.stdin.readline().strip()
n = int(input())
a = sorted([(int(x), i) for (i, x) in enumerate(input().split(), start=1)])
for i in range(n // 2):
	print(a[i][1], a[-i - 1][1])


n = int(input())
c = list(map(int, input().split()))
tot = sum(c) // (n // 2)
b = [0] * len(c)
for i in range(n):
	if b[i] == 0:
		p = i + 1 + c[i + 1:].index(tot - c[i])
		b[p] = 1
		b[i] = 1
		if c[i] <= c[p]:
			print(i + 1, p + 1)
		else:
			print(p + 1, i + 1)
		c[i] = -1
		c[p] = -1


n = int(input())
ai = list(map(int, input().split()))
ai2 = list(range(1, n + 1))
for i in range(n):
	for j in range(i + 1, n):
		if ai[j] > ai[i]:
			temp = ai[i]
			ai[i] = ai[j]
			ai[j] = temp
			temp = ai2[i]
			ai2[i] = ai2[j]
			ai2[j] = temp
for i in range(n // 2):
	print(ai2[i], ai2[n - 1 - i])


n = int(input())
s = list(map(int, input().split()))
dif = 2 * sum(s) // n
t = []
for i in range(n):
	for j in range(n):
		if s[i] + s[j] == dif and i not in t and (j not in t) and (i != j):
			print(i + 1, j + 1)
			t.append(i)
			t.append(j)


n = int(input())
cards = [int(num) for num in input().split(' ')]
sr_value = int(sum(cards) * 2 / n)
for i in range(n - 1):
	for j in range(i + 1, n):
		if cards[i] != 0 and cards[j] != 0 and (cards[i] + cards[j] == sr_value):
			print(i + 1, j + 1)
			cards[i] = 0
			cards[j] = 0


n = int(input())
cards = list(map(int, input().split()))
used = [False] * n
total = 0
for card in cards:
	total += card
m = total / (n / 2)
for i in range(int(n / 2)):
	res = ''
	for j in range(n):
		if not used[j]:
			used[j] = True
			res += str(j + 1)
			res += ' '
			for k in range(n):
				if not used[k]:
					if cards[j] + cards[k] == m:
						used[k] = True
						res += str(k + 1)
						break
			break
	print(res)


n = int(input())
a = list(map(int, input().split()))
a = list(zip(a, range(1, n + 1)))
a.sort()
for i in range(n >> 1):
	print('{0} {1}'.format(a[i][1], a[-i - 1][1]))


n = int(input())
lst = [int(i) for i in input().split()]
d = {}
for i in range(len(lst)):
	if lst[i] not in d:
		d[lst[i]] = [i + 1]
	else:
		d[lst[i]].append(i + 1)
lst.sort()
for i in range(len(lst) // 2):
	print(d[lst[i]][-1], end=' ')
	d[lst[i]].pop()
	print(d[lst[-1 - i]][-1])
	d[lst[-1 - i]].pop()


n = int(input())
a = [int(i) for i in input().split()]
k = 0
for i in range(n):
	k += a[i]
k = round(2 * k / n)
for i in range(n):
	if a[i] != 0:
		print(i + 1, end=' ')
		for j in range(i + 1, n):
			if a[j] == k - a[i]:
				print(j + 1)
				a[j] = 0
				break


n = int(input())
a = list(map(int, input().split()))
sa = sum(a) / (n / 2)
b = []
for i in range(len(a)):
	for j in range(len(a)):
		if i != j:
			if a[i] + a[j] == sa:
				print(i + 1, j + 1)
				a[i] = 0
				a[j] = 0


n = int(input())
a = list(map(int, input().split()))
mx = max(a)
lst = []
for i in range(n):
	ind = a.index(min(a))
	lst.append(ind + 1)
	a[ind] = mx + 1
for i in range(n // 2):
	print(lst[i], lst[n - i - 1])


def solve(test):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a) * 2 // n
	for i in range(n):
		for j in range(i + 1, n):
			if a[i] + a[j] == s:
				print(i + 1, j + 1)
				a[j] = 10 ** 10
				break
t = 1
for _ in range(t):
	solve(_ + 1)


n = int(input())
a = list(map(int, input().split()))
sum = 0
flag = []
for i in range(0, n + 1):
	flag.append(0)
lag = flag
for i in a:
	sum = sum + i
sum = sum // (n / 2)
for i in range(n + 1):
	for j in range(i, n):
		if a[i] + a[j] == sum and i != j and (flag[i] == 0) and (lag[j] == 0):
			flag[i] = 1
			lag[j] = 1
			print(i + 1, j + 1)


n = int(input())
cards = list(map(int, input().split()))
s = sorted([(int(cards[i]), i + 1) for i in range(n)])
for i in range(n // 2):
	print(s[i][1], s[-1 - i][1])


i = int(input())
l = list(map(int, input().split()))
a = sum(l) // (i // 2)
for x in range(len(l)):
	if l[x] != '*':
		b = l[x]
		for y in range(x + 1, len(l)):
			c = a - b
			if l[y] == c:
				print(x + 1, y + 1)
				l[y] = '*'
				break


def sol(A):
	n = len(A)
	V = [0] * n
	summ = min(A) + max(A)
	pairs = []
	for i in range(n):
		for j in range(i, n):
			if A[i] + A[j] == summ and V[i] == 0 and (V[j] == 0) and (i != j):
				(V[i], V[j]) = (1, 1)
				pairs.append([i, j])
	return pairs
n = int(input())
A = [int(item) for item in input().split()]
pairs = sol(A)
for i in pairs:
	print(i[0] + 1, i[1] + 1)


n = int(input())
l = input().strip().split()
tp = sorted([(int(l[i]), i + 1) for i in range(n)])
for i in range(n // 2):
	print(tp[i][1], tp[-1 - i][1])


n = int(input())
l = list(map(int, input().split()))
nx = n / 2
sm = int(sum(l) / nx)
nl = []
for i in range(n):
	if i not in nl:
		nl.append(i)
		for j in range(i + 1, n):
			if l[i] + l[j] == sm and j not in nl:
				print(i + 1, j + 1)
				nl.append(j)
				break


n = int(input())
s = [int(i) for i in input().split()]
t = []
for i in range(n):
	t.append((s[i], i + 1))
r = sum(s) // (n // 2)
t.sort()
for i in range(n // 2):
	print(t[i][1], t[n - i - 1][1])


z = int(input())
x = list(map(int, input().split()))
f = sorted(x)
a = -1
for c in range(z // 2):
	q = x.index(f[c]) + 1
	x[x.index(f[c])] = 0
	w = x.index(f[a]) + 1
	x[x.index(f[a])] = 0
	print(q, w)
	a -= 1


n = int(input())
arr = list(map(int, input().split()))
s = sum(arr) // (n // 2)
memo = {i: False for i in range(n)}
for i in range(n):
	if memo[i] == False:
		for j in range(i + 1, n):
			if memo[j] == False and arr[j] == s - arr[i]:
				memo[j] = True
				memo[i] = True
				break
		print(i + 1, j + 1)


n = int(input())
ls = list(map(int, input().split()))
sum = 2 * sum(ls) // n
visited = {}
for i in range(1, n + 1):
	visited[i] = False
for i in range(1, n + 1):
	for j in range(1, n + 1):
		if visited[i] or visited[j] or i == j:
			pass
		elif ls[i - 1] + ls[j - 1] == sum:
			print(i, j)
			visited[i] = True
			visited[j] = True


import sys
n = int(input())
arr = list(map(int, input().split()))
arr2 = sorted(arr)
s = -1
found = 0
indexx = []
for i in range(int(n / 2)):
	for j in range(n):
		if j + 1 not in indexx and arr[j] == arr2[i]:
			indexx.append(j + 1)
			pos1 = j + 1
			break
	for j in range(n):
		if j + 1 not in indexx and arr[j] == arr2[n - i - 1]:
			indexx.append(j + 1)
			pos2 = j + 1
			break
	print(pos1, pos2)


def main():
	n = int(input())
	l = list(map(int, input().split()))
	idx = sorted(range(n), key=l.__getitem__)
	for (a, b) in zip(idx[:n // 2], idx[::-1]):
		print(a + 1, b + 1)
main()


n = int(input())
nums = [int(i) for i in input().split()]
summa = sum(nums) * 2 // n
for (pos, val) in enumerate(nums):
	if val == 0:
		continue
	nums[pos] = 0
	matching = nums.index(summa - val)
	nums[matching] = 0
	print(pos + 1, matching + 1)


n = int(input())
c = list(map(int, input().split()))
a = 2 * sum(c) // n
s = [(b, a - b) for b in sorted(c)[:n // 2] if a - b in set(c) and b <= a // 2]
for (x, y) in s:
	cx = c.index(x)
	c[cx] = 0
	cy = c.index(y)
	c[cy] = 0
	print(cx + 1, cy + 1)


n = int(input())
l = list(map(int, input().split()))
x = int(sum(l) / n * 2)
y = []
for i in range(n):
	for j in range(i + 1, n):
		if i + 1 not in y and j + 1 not in y:
			if l[i] + l[j] == x:
				print(i + 1, j + 1)
				y.append(i + 1)
				y.append(j + 1)


n = int(input())
arr = [int(x) for x in input().split()]
sum = sum(arr)
sum1 = sum // (n // 2)
k = 1000
for i in range(0, len(arr) - 1, 1):
	if arr[i] > 100:
		continue
	for j in range(i + 1, len(arr), 1):
		if arr[i] + arr[j] == sum1:
			if (i + 1) % 2 == 0 and (j + 1) % 2 == 0:
				print(j + 1, i + 1)
				arr[j] = k
				k += 1
				break
			else:
				print(i + 1, j + 1)
				arr[j] = k
				k += 1
				break


M = tuple(([] for i in range(100)))
s = 0
n = int(input()) >> 1
for (i, e) in enumerate(map(int, input().split())):
	e -= 1
	s += e
	M[e].append(1 + i)
s //= n
for (i, e) in enumerate(M):
	while e:
		n -= 1
		print(e.pop(), M[s - i].pop())
	if not n:
		break


n = int(int(input()) / 2)
a = list(map(int, input().split()))
x = int(sum(a) / n)
b = []
for i in range(len(a)):
	if i in b:
		continue
	else:
		for j in range(i + 1, len(a)):
			if j in b:
				continue
			if a[i] + a[j] == x:
				print(i + 1, j + 1, sep=' ')
				b.append(i)
				b.append(j)
				break


n = int(input())
ar = list(map(int, input().split()))
su = int(sum(ar) / n * 2)
for i in range(n):
	for j in range(i + 1, n):
		if not ar[i] or not ar[j]:
			continue
		if ar[i] + ar[j] == su:
			print(i + 1, j + 1)
			(ar[i], ar[j]) = (0, 0)


n = input()
a = input()
a = a.split(' ')
l = []
for i in a:
	l.append(int(i))
lsorted = sorted(l)
index = []
for i in range(len(l)):
	index.append(l.index(lsorted[i]))
	l[l.index(lsorted[i])] = -1
same = True
for i in range(1, len(l)):
	if lsorted[i] != lsorted[i - 1]:
		same = False
for i in range(int(len(l) / 2)):
	print(index[i] + 1, index[len(l) - i - 1] + 1)


n = int(input())
text = input()
x = []
c = 0
for i in range(0, n):
	x.append(int(text.split(' ')[i]))
	c += int(text.split(' ')[i])
c = c / (n / 2)
history = []
sch = 0
for i in range(0, len(x)):
	for b in range(0, len(x)):
		if i != b:
			if history.count(str(b)) == 0 and history.count(str(i)) == 0:
				if x[i] + x[b] == c:
					print(i + 1, b + 1)
					history.append(str(b))
					history.append(str(i))
					sch += 1
					break
			if sch == n / 2:
				break
	if sch == n / 2:
		break


n = int(input())
a = [int(x) for x in input().split()]
a_i = [[a[x], x + 1] for x in range(n)]
a_i.sort()
a_i[int(n / 2):].sort(reverse=True)
for b in range(int(n / 2)):
	print(a_i[b][1], a_i[n - b - 1][1])


n = int(input())
a = list(map(int, input().split()))
b = sum(a) // (n // 2)
d = []
for i in range(n):
	for j in range(n):
		if a[i] + a[j] == b and j > i:
			if i + 1 not in d and j + 1 not in d:
				d.append(i + 1)
				d.append(j + 1)
for i in range(n // 2):
	print(d[0], d[1])
	d.pop(0)
	d.pop(0)


n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
for i in range(n // 2):
	s = b[i]
	t = a.index(s)
	print(t + 1, end=' ')
	a[t] = -1
	e = b[-i - 1]
	r = a.index(e)
	print(r + 1)
	a[r] = -1


n = int(input())
m = list(map(int, input().split()))
a = list(m)
a.sort(reverse=True)
for i in range(n // 2):
	b = m.index(a[0])
	m[b] = None
	c = m.index(a[-1])
	m[c] = None
	print(b + 1, c + 1)
	a = a[1:-1]


def answer():
	targ = int(input())
	a = [int(x) for x in input().split()]
	targ = sum(a) / len(a) * 2
	i = 0
	paired = []
	while i < len(a):
		if i not in paired:
			j = i + 1
			while j < len(a) and j != i:
				if j not in paired:
					if a[i] + a[j] == targ:
						paired.append(i)
						paired.append(j)
						print(i + 1, j + 1)
						break
				j += 1
		i += 1
answer()


n = int(input())
l = list(map(int, input().split()))
m = sorted(l)
s = m[0] + m[n - 1]
c = 0
for i in range(n):
	for j in range(i + 1, n):
		if l[i] + l[j] == s:
			print(i + 1, j + 1)
			l[i] = 0
			l[j] = 0


import math
n = int(input())
a = list(map(int, input().split()))
su = sum(a) / (n // 2)
for i in range(n):
	if a[i] != -1:
		t = a[i]
		a[i] = -1
		idx = a.index(su - t)
		print('{0} {1}'.format(i + 1, idx + 1))
		a[idx] = -1


n = int(input())
list1 = list(map(int, input().split()))
list2 = list1 + []
list2.sort()
for i in range(0, n // 2):
	p = list1.index(list2[i])
	list1[p] = -1
	q = list1.index(list2[n - i - 1])
	list1[q] = -1
	print(p + 1, q + 1)


import math
n = int(input())
q = [int(x) for x in input().split()]
avg = sum(q) * 2 // n
for i in range(n - 1):
	for j in range(i + 1, n):
		if q[i] + q[j] == avg:
			print(i + 1, end=' ')
			print(j + 1, end=' ')
			q[i] = -999
			q[j] = -999
			print()


def ind(N, el, B, A):
	for i in range(N):
		if B[i]:
			if A[i] == el:
				return i
	return 0
N = int(input())
A = list(map(int, input().split()))
B = [True for i in range(N)]
summ = sum(A) * 2 // N
for i in range(N):
	if B[i]:
		B[i] = False
		x = ind(N, summ - A[i], B, A)
		B[x] = False
		print(i + 1, x + 1)


import sys
cards = int(input())
players = cards // 2
card_values = [int(i) for i in input().split()]
avg = sum(card_values) // players
used = [False for i in range(cards)]
for i in range(cards):
	if not used[i]:
		card_value = card_values[i]
		j = next((j for j in range(i + 1, cards) if not used[j] and avg == card_values[j] + card_value))
		print(i + 1, j + 1)
		used[i] = True
		used[j] = True


n = int(input())
m = list(map(int, input().split()))
aa = list.copy(m)
aa.sort()
dd = aa[0] + aa[-1]
igr = [n + 1]
for i in range(n):
	qq = m[i]
	for j in range(i + 1, n):
		ww = m[j]
		for jj in igr:
			ee = m.index(m[i])
			pp = m.index(m[j])
			if m.index(m[i]) != jj and m.index(m[j]) != jj and (dd - m[j] == m[i]):
				igr.append([i + 1, j + 1])
				m.remove(m[i])
				m.insert(i, 111)
				m.remove(m[j])
				m.insert(j, 111)
				break
igr.remove(n + 1)
for tt in igr:
	for pp in tt:
		print(pp, end=' ')
	print()


n = int(input())
a = n * [0]
i = 0
x = list(map(int, input().split()))
while i != n:
	for j in range(i + 1, n):
		if x[i] + x[j] == 2 * sum(x) // n and a[i] == 0 and (a[j] == 0):
			a[i] = x[i]
			a[j] = x[j]
			print(i + 1, j + 1)
			break
	i += 1


n = int(input())
l = list(map(int, input().split()))
S = sum(l)
p = S // (n // 2)
for i in range(n):
	for j in range(n):
		if l[i] + l[j] == p and i != j and (l[i] != -1) and (l[j] != -1):
			print(i + 1, j + 1)
			l[i] = -1
			l[j] = -1
			break


n = int(input())
Y = sorted(zip(map(int, input().split()), range(1, 1 + n)))
for i in range(n >> 1):
	print(Y[i][1], Y[-1 - i][1])


def main():
	n = int(input())
	a = list(map(int, input().split(' ')))
	sum = 0
	for x in a:
		sum += x
	one = 2 * sum // n
	used = [False] * n
	for (i, x) in enumerate(a):
		if not used[i]:
			used[i] = True
			for (j, y) in enumerate(a):
				if not used[j] and y == one - x:
					used[j] = True
					print(i + 1, j + 1, end='\n')
					break
main()


s = int(input())
t = input()
a = t.split(' ')
x = []
for i in a:
	x.append(int(i))
z = sum(x) // (s // 2)
for i in range(len(x)):
	if x[i] != -1:
		new = x[i]
		x[i] = -1
		find = z - new
		pailam = x.index(find)
		x[pailam] = -1
		print(i + 1, pailam + 1)


n = int(input())
a = [int(i) for i in input().split()]
z = sum(a)
z = z / len(a) * 2
s = len(a) * [0]
for i in range(len(a)):
	for j in range(len(a)):
		if i != j:
			if a[i] + a[j] == z and s[i] != 1 and (s[j] != 1):
				print(i + 1, j + 1, end=' ')
				print()
				s[i] = 1
				s[j] = 1


n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
	b.append(0)
s = 0
for i in range(n):
	s += a[i]
sn = s // (n // 2)
j = 0
while j != n - 1:
	if b[j] == 0:
		b[j] = 1
		for k in range(n):
			if sn - a[k] == a[j] and b[k] == 0:
				print(j + 1, k + 1)
				b[k] = 1
				break
	j += 1


n = int(input())
cards = list(map(int, input().split()))
each_sum = sum(cards) // (n // 2)
for i in range(n):
	if cards[i] != 0:
		for j in range(n):
			if cards[i] + cards[j] == each_sum and i != j:
				print(i + 1, j + 1)
				(cards[i], cards[j]) = (0, 0)
				break


n = int(input())
l = list(map(int, input().split()))
l_sum = sum(l)
p_sum = 2 * l_sum // n
d = [None] * 101
for i in range(n):
	c_diff = p_sum - l[i]
	if d[c_diff] == None or len(d[c_diff]) == 0:
		if d[l[i]] == None:
			d[l[i]] = [i]
		else:
			d[l[i]].append(i)
	else:
		idx = d[c_diff].pop()
		print(i + 1, idx + 1)


numbers = []
n = int(input())
i = 1
for x in input().split():
	numbers.append((int(x), i))
	i += 1
numbers = sorted(numbers)
for x in range(n // 2):
	print(numbers[x][1], numbers[n - x - 1][1])


from collections import defaultdict

def solve(n, c):
	x = c[:]
	d = defaultdict(list)
	for (i, v) in enumerate(c):
		d[v].append(i)
	x.sort()
	for i in range(n // 2):
		a = d[x[i]].pop()
		b = d[x[n - 1 - i]].pop()
		print(a + 1, b + 1)

def main():
	n = int(input())
	c = list(map(int, input().split()))
	solve(n, c)
main()


n = int(input())
a = [int(s) for s in input().split(' ')]
taken = []
for i in range(n):
	if i + 1 not in taken:
		for j in range(i + 1, n):
			if j + 1 not in taken and a[i] + a[j] == 2 * sum(a) // n:
				taken.append(i + 1)
				taken.append(j + 1)
				break
for k in range(n // 2):
	print(taken[2 * k], taken[2 * k + 1])


n = int(input())
arr = [0] * 201
counter = 1
for i in range(201):
	arr[int(i)] = list()
for i in input().split():
	arr[int(i)].append(counter)
	counter = counter + 1
for i in range(2, 201):
	rpta = list()
	cnt = 0
	val = i // 2 + 1 if i % 2 == 1 else i // 2
	for j in range(val):
		if len(arr[j]) != 0:
			cnt = cnt + min(len(arr[j]), len(arr[i - j]))
			for k in range(min(len(arr[j]), len(arr[i - j]))):
				rpta.append((arr[j][k], arr[i - j][k]))
	if i % 2 == 0:
		cnt = cnt + len(arr[i // 2]) // 2
		for k in range(len(arr[i // 2]) // 2):
			rpta.append((arr[i // 2][2 * k], arr[i // 2][2 * k + 1]))
	if cnt == n // 2:
		for (i, j) in rpta:
			print(str(i) + ' ' + str(j))
		exit()
	del rpta[:]


n = int(input())
num = input()
a = []

def get_the_data(count, num, arr):
	for i in range(0, len(num)):
		if num[i] == ' ':
			arr.append(int(num[count:i]))
			count = i + 1
		elif i == len(num) - 1:
			arr.append(int(num[count:len(num)]))
	return arr
arr = get_the_data(0, num, a)
max = arr[0:len(arr)]
max.sort()
target = max[0] + max[len(max) - 1]
i = 0
data = [False] * len(arr)
while i < len(arr) - 1:
	k = target - arr[i]
	if data[i] == False:
		for j in range(len(arr) - 1, i, -1):
			if arr[j] == k and data[j] == False:
				data[j] = True
				print(str(i + 1) + ' ' + str(j + 1))
				break
	i += 1


def main():
	n = int(input())
	nums = [int(x) for x in input().split(' ')]
	done = [0] * n
	q = sum(nums) // (n // 2)
	for (i, x) in enumerate(nums):
		if not done[i]:
			done[i] = 1
			y = q - x
			for j in range(i + 1, n):
				if nums[j] == y and (not done[j]):
					done[j] = 1
					print(i + 1, j + 1)
					break
main()


n = int(input())
line = list(map(int, input().split()))
Sum = int(sum(line) / (n / 2))
matrix = []
Count = a = 0
check = []
check2 = []
for i in range(n):
	for j in range(n):
		if i not in check and j not in check2 and (j not in check) and (i not in check2):
			if i != j:
				if line[i] + line[j] == Sum:
					matrix.append((i + 1, j + 1))
					check.append(i)
					check2.append(j)
for i in matrix:
	for j in i:
		print(j, end=' ')
	print()


n = int(input())
m = input().split()
z = n // 2
sum = 0
s = []
for i in range(n):
	sum += int(m[i])
for i in range(n):
	for j in range(n):
		if i not in s and j not in s and (i != j):
			if int(m[i]) + int(m[j]) == sum // z:
				print(i + 1, ' ', j + 1)
				s.append(i)
				s.append(j)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	n = I()
	l = LI()
	l2 = []
	for (i, x) in enumerate(l):
		l2.append([i, x])
	l2 = sorted(l2, key=lambda x: x[1])
	for i in range(n // 2):
		print(l2[i][0] + 1, l2[n - i - 1][0] + 1)
main()


def main():
	n = int(input())
	vals = [(int(v), i) for (i, v) in enumerate(input().split())]
	vals.sort()
	for i in range(n // 2):
		print(vals[i][1] + 1, vals[n - i - 1][1] + 1)
main()


n = int(input())
a = list(map(int, input().split()))
l = []
l.extend(a)
l.sort()
for i in range(n // 2):
	m = a.index(l[i])
	a[m] = 0
	p = a.index(l[n - i - 1])
	a[p] = 0
	print(m + 1, p + 1)


import sys
n = int(input())
arr = list(map(int, input().split()))
arr2 = sorted(arr)
arr3 = []
for i in range(n):
	j = i + 1
	a = arr2[i]
	b = arr2[n - j]
	for k in range(n):
		if arr[k] == a and k + 1 not in arr3:
			arr3.append(k + 1)
			break
	for l in range(n):
		if arr[l] == b and l + 1 not in arr3:
			arr3.append(l + 1)
			break
	if i == int(n / 2) - 1:
		break
for k in range(0, n - 1, 2):
	print(arr3[k], arr3[k + 1])


n = int(input())
a = list(map(int, input().split()))
p = []
s = sum(a) * 2 // n
for i in range(n):
	c = a[i]
	found = False
	for j in range(len(p)):
		if len(p[j]) == 1 and a[p[j][0]] == s - c:
			p[j].append(i)
			found = True
			break
	if not found:
		p.append([i])
for pp in p:
	print(pp[0] + 1, pp[1] + 1)


n = int(input())
a = list(map(int, input().split()))
spis = [False] * n
b = sum(a) / (n / 2)
i = 0
k = 1
while i < n:
	while k < n:
		if a[i] + a[k] == b and spis[i] == False and (spis[k] == False):
			spis[i] = True
			spis[k] = True
			print(i + 1, k + 1)
		k = k + 1
	i = i + 1
	k = i + 1


def pro():
	n = int(input())
	h = list(map(int, input().split()))
	q = h.copy()
	q.sort()
	for i in range(n // 2):
		print(h.index(q[i]) + 1, end=' ')
		h[h.index(q[i])] = -1
		print(h.index(q[-1 - i]) + 1)
		h[h.index(q[-1 - i])] = -1
pro()


n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
	if i in b:
		continue
	else:
		print(i + 1, end=' ')
		b.append(i)
		for j in range(i + 1, n):
			if a[j] + a[i] == sum(a) // (n // 2) and j not in b:
				print(j + 1)
				b.append(j)
				break


def Bitplus():
	n = int(input())
	x = 0
	for i in range(n):
		a = input()
		if '+' in a:
			x += 1
		else:
			x -= 1
	print(x)

def GiftSetidk():
	n = int(input())
	for i in range(n):
		all = input().split(' ')
		x = int(all[0])
		y = int(all[1])
		a = int(all[2])
		b = int(all[3])
		counter = 0
		count = True
		while count:
			if x >= a and y >= b:
				x -= a
				y -= b
				counter += 1
			elif x >= b and y >= a:
				x -= b
				y -= a
				counter += 1
			else:
				count = False
		print(counter)

def Team():
	n = int(input())
	problemcount = 0
	for i in range(n):
		count = 0
		answer = input().split(' ')
		for i in range(len(answer)):
			answer[i] = int(answer[i])
		for i in answer:
			if i == 1:
				count += 1
		if count >= 2:
			problemcount += 1
	print(problemcount)

def NextRound():
	nk = input().split(' ')
	n = int(nk[0])
	k = int(nk[1])
	print(n, k)
	scores = input().split(' ')
	count = 0
	for i in range(n):
		scores[i] = int(scores[i])
	five = scores[k]
	for i in range(n):
		if scores[i] >= five and scores[i] > 0:
			count += 1
	print(count)

def Beautifulmatrix():
	steps = 0
	matrixes = []
	for i in range(5):
		i = [input().split(' ')]
		matrixes += i
	for i in range(5):
		for j in range(5):
			matrixes[i][j] = int(matrixes[i][j])
	for i in range(5):
		for j in range(5):
			if matrixes[i][j] > 0:
				x = j
				y = i
				break
	while x != 2 or y != 2:
		if x > 2:
			x -= 1
			steps += 1
		elif x < 2:
			x += 1
			steps += 1
		elif y > 2:
			y -= 1
			steps += 1
		elif y < 2:
			y += 1
			steps += 1
	print(steps)

def HelpfulMahts():
	s = input().split('+')
	s.sort()
	print('+'.join(s))

def WordCapitalization():
	word = input()
	List = []
	for i in word:
		List.append(i)
	List[0] = List[0].upper()
	s = ''
	for i in List:
		s += i
	print(s)

def Stonesonthetable():
	n = int(input())
	stones = []
	rrg = input()
	counter = 0
	for i in rrg:
		stones.append(i)
	for i in range(n - 1):
		if stones[i] == stones[i + 1]:
			counter += 1
	print(counter)

def BearandBigBrother():
	inpuut = input().split(' ')
	a = int(inpuut[0])
	b = int(inpuut[1])
	year = 0
	while a <= b:
		a *= 3
		b *= 2
		year += 1
	print(year)

def Wrongsubtraction():
	nk = input().split(' ')
	n = int(nk[0])
	k = int(nk[1])
	for i in range(k):
		p = str(n)
		if p[len(p) - 1] == '0':
			n //= 10
		else:
			n -= 1
	print(n)
import string

def Word():
	word = input()
	lower = 0
	upper = 0
	for i in word:
		if i in string.ascii_lowercase:
			lower += 1
		else:
			upper += 1
	if upper > lower:
		word = word.upper()
	else:
		word = word.lower()
	print(word)

def QueueattheSchool():
	nt = input().split(' ')
	n = nt[0]
	t = int(nt[1])
	a = input()
	b = []
	ref = ''
	for i in a:
		b.append(i)
	for k in range(t):
		whre = []
		for i in range(len(b) - 1):
			if b[i] == 'B' and b[i + 1] != 'B':
				whre.insert(0, i)
		for j in whre:
			b.pop(j)
			b.insert(j + 1, 'B')
	for i in b:
		ref += i
	print(ref)

def Nearlyluckynumber():
	n = input()
	if n.count('7') + n.count('4') == 7 or n.count('7') + n.count('4') == 4:
		print('YES')
	else:
		print('NO')

def Translation():
	s = input()
	t = input()
	n = []
	for i in t:
		n.insert(0, i)
	t = ''
	for i in n:
		t += i
	if t == s:
		print('YES')
	else:
		print('NO')

def ANTONandDanik():
	n = int(input())
	s = input()
	A = s.count('A')
	D = s.count('D')
	if A > D:
		print('Anton')
	elif D > A:
		print('Danik')
	else:
		print('Friendship')

def GeorgeandAccomodation():
	n = int(input())
	rooms = 0
	for i in range(n):
		pq = input().split(' ')
		p = int(pq[0])
		q = int(pq[1])
		if q - p >= 2:
			rooms += 1
	print(rooms)

def Magnets():
	n = int(input())
	Rows = []
	groups = 1
	for i in range(n):
		Rows += [input()]
	for i in range(n - 1):
		if Rows[i] != Rows[i + 1]:
			groups += 1
	print(groups)

def InSearcoanEasyProblem():
	n = int(input())
	counter = 0
	s = input().split(' ')
	if '1' in s:
		print('HARD')
	else:
		print('EASY')

def Hulk():
	c = int(input())
	i = 'I'
	s = ''
	it = 'it'
	for i in range(1, c + 1):
		if i == 1:
			s += 'hate '
		elif i % 2 == 0:
			s += 'that I love '
		else:
			s += 'that I hate '
	print(f'I {s}it')

def CalculatingFunctionidk():
	n = int(input())
	c = 0
	for i in range(1, n + 1):
		if i % 2 != 0:
			c -= i
		else:
			c += i
	print(c)

def IWannaBetheGuyidk():
	n = int(input())
	p = input().split(' ')
	q = input().split(' ')
	counter = 0
	for i in range(1, n + 1):
		if str(i) in p or str(i) in q:
			counter += 1
	if counter == n:
		print('I become the guy.')
	else:
		print('Oh, my keyboard!')

def horsesheo():
	n = input().split(' ')
	many = 4
	whatwas = []
	for i in range(len(n)):
		n[i] = int(n[i])
		if n[i] not in whatwas:
			whatwas.append(n[i])
	print(many - len(whatwas))

def ArrivaloftheGeneralidk():
	n = int(input())
	a = input().split(' ')
	max = 0
	minlist = []
	for i in range(n):
		a[i] = int(a[i])
	for i in a:
		if i > max:
			max = i
	maxloc = a.index(max)
	for i in a:
		minlist.insert(0, i)
	min = max
	for i in a:
		if i < min:
			min = i
	minloc = minlist.index(min)
	print(minloc + maxloc)

def UltraFastMathematician():
	first = input()
	second = input()
	s = ''
	for i in range(len(first)):
		if first[i] == '0' and second[i] == '1':
			s += '1'
		elif first[i] == '1' and second[i] == '0':
			s += '1'
		elif first[i] == '0' and second[i] == '0':
			s += '0'
		elif first[i] == '1' and second[i] == '1':
			s += '0'
	print(s)

def Insomniacure():
	klmn = []
	for i in range(4):
		klmn.append(int(input()))
	d = int(input())
	List = []
	if 1 in klmn:
		return d
	for i in range(4):
		mulit = klmn[i]
		while klmn[i] <= d:
			if klmn[i] not in List:
				List.append(klmn[i])
			klmn[i] += mulit
	return len(List)

def AntonandLetters():
	first = input()
	List = []
	for i in first:
		if i not in List and i in string.ascii_lowercase:
			List.append(i)
	print(len(List))

def Pangram():
	n = int(input())
	word = input().lower()
	List = []
	if n >= 26:
		for i in word:
			if i not in List:
				List.append(i)
		if len(List) == 26:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')

def Collectingcoons():
	n = int(input())
	for i in range(n):
		abcd = input().split(' ')
		for i in range(len(abcd)):
			abcd[i] = int(abcd[i])
		d = abcd[3]
		abcd.pop()
		maxi = 0
		for i in abcd:
			if i > maxi:
				maxi = i
		allindexes = [0, 1, 2]
		indexmax = abcd.index(maxi)
		allindexes.pop(indexmax)
		allminus = 0
		for i in allindexes:
			allminus += abcd[indexmax] - abcd[i]
		d -= allminus
		if d % 3 == 0 and d >= 0:
			print('YES')
		else:
			print('NO')

def Brainsphotos():
	nm = input().split(' ')
	colors = []
	for i in range(int(nm[0])):
		colors += input().split(' ')
	for i in colors:
		if i == 'C' or i == 'M' or i == 'Y':
			return '#Color'
	return '#Black&White'

def SerejaandDima():
	n = int(input())
	card = input().split(' ')
	S = 0
	D = 0
	sturn = True
	for i in range(n):
		if int(card[0]) > int(card[len(card) - 1]):
			if sturn:
				S += int(card[0])
				card.pop(0)
				sturn = False
			else:
				D += int(card[0])
				card.pop(0)
				sturn = True
		elif sturn:
			S += int(card[len(card) - 1])
			card.pop(len(card) - 1)
			sturn = False
		else:
			D += int(card[len(card) - 1])
			card.pop(len(card) - 1)
			sturn = True
	print(f'{S} {D}')

def Vanyaandcubes():
	n = int(input())
	counter = 1
	countdodo = 0
	rows = 0
	while n > 0:
		countdodo += counter
		counter += 1
		rows += 1
		n -= countdodo
	if n == 0:
		print(rows)
	else:
		print(rows - 1)

def GennadyandaCarGame():
	card = input()
	cards = input().replace(' ', '')
	for i in card:
		for j in cards:
			if i == j:
				return 'YES'
	return 'NO'

def FafaandhisCompany():
	n = int(input())
	ways = 0
	for i in range(1, n):
		a = n
		a -= i
		if a % i == 0:
			ways += 1
	print(ways)

def Mahmoudandehabandtheevenoddgame():
	n = int(input())
	Mahmoudsturn = True
	Mahmoudlsot = False
	Ehablost = False
	a = 0
	while not Mahmoudlsot and (not Ehablost):
		if Mahmoudsturn:
			if n % 2 == 0 and n >= 2:
				Ehablost = True
			elif n % 2 != 0 and n >= 2:
				a = n - 1
			else:
				Mahmoudlsot = True
		elif n % 2 == 1 and n >= 1:
			Mahmoudlsot = True
		elif n % 2 == 0 and n >= 1:
			a = n - 1
		else:
			Ehablost = False
		n -= a
		if Mahmoudsturn == True:
			Mahmoudsturn = False
		else:
			Mahmoudsturn = True
	if Mahmoudlsot == True:
		print('Ehab')
	else:
		print('Mahmoud')

def FloorNumber():
	t = int(input())
	for i in range(t):
		nx = input().split(' ')
		n = int(nx[0])
		x = int(nx[1])
		aparteements = 2
		floor = 1
		while n > aparteements:
			aparteements += x
			floor += 1
		print(floor)

def VustheCossackandaContest():
	nmk = input().split(' ')
	n = int(nmk[0])
	m = int(nmk[1])
	k = int(nmk[2])
	if n <= m and n <= k:
		print('Yes')
	else:
		print('No')

def NightattheMuseum():
	word = input()
	rotations = 0
	lower = string.ascii_lowercase + string.ascii_lowercase + string.ascii_lowercase
	loc = lower.index('a', 26, 2 * 26)
	for i in word:
		cplus = loc
		cminus = loc
		keep = True
		while keep:
			if i == lower[cplus] or i == lower[cminus]:
				keep = False
			else:
				cplus += 1
				cminus -= 1
				rotations += 1
				loc = lower.index(i, 26, 2 * 26)
	print(rotations)

def OrdinarYnumbers():
	n = int(input())
	for i in range(n):
		k = int(input())
		counter = 0
		for j in range(1, k + 1):
			a = str(j)
			if len(a) == a.count(a[0]):
				counter += 1
		print(counter)

def DieRoll():
	n = input().split(' ')
	y = int(n[0])
	w = int(n[1])
	number = 0
	dec = 6
	if y >= w:
		for i in range(y, 7):
			number += 1
	else:
		for i in range(w, 7):
			number += 1
	if number % 6 == 0:
		number = number // 6
		dec = 1
	elif number % 3 == 0:
		number = number // 3
		dec = 2
	elif number % 2 == 0:
		number = number // 2
		dec = 3
	print(f'{number}/{dec}')

def Borze():
	n = input()
	l = ''
	k = ''
	for i in n:
		if i == '.' and len(l) == 0:
			k += '0'
		else:
			l += i
			if len(l) == 2:
				if l == '-.':
					k += '1'
					l = ''
				else:
					k += '2'
					l = ''
	print(k)

def FairPlayoff():
	n = int(input())
	for i in range(n):
		loser = {}
		winner = {}
		count = 0
		k = input().split(' ')
		if int(k[0]) > int(k[1]):
			loser['one'] = int(k[1])
			winner['two'] = int(k[0])
		else:
			loser['one'] = int(k[0])
			winner['two'] = int(k[1])
		if int(k[2]) > int(k[3]):
			loser['two'] = int(k[3])
			winner['one'] = int(k[2])
		else:
			loser['two'] = int(k[2])
			winner['one'] = int(k[3])
		for i in loser:
			if loser[i] < winner[i]:
				count += 1
		if count >= 2:
			print('YES')
		else:
			print('NO')

def Bustoudaylanbd():
	n = int(input())
	s = []
	rem = -1
	first = True
	ss = ''
	for i in range(n):
		s += input().split('|')
	for i in range(len(s)):
		if s[i] == 'OO' and first:
			rem = i
			s[i] = '++'
			first = False
	for i in range(len(s)):
		if i % 2 == 0:
			ss += s[i] + '|'
		else:
			ss += s[i] + '\n'
	if not first:
		print('YES')
		print(ss)
	else:
		print('NO')

def Maximumincrease():
	n = int(input())
	arraa = input().split(' ')
	for i in range(len(arraa)):
		arraa[i] = int(arraa[i])
	counter = {}
	for i in range(n):
		counter[i] = 0
	count = 0
	last = 0
	for i in arraa:
		if i > last:
			last = i
			counter[count] += 1
		else:
			last = i
			count += 1
			counter[count] += 1
	max = 0
	for i in range(n):
		if counter[i] > max:
			max = counter[i]
	print(max)

def Jugglingletters():
	n = int(input())
	for i in range(n):
		k = int(input())
		s = ''
		map = {}
		possible = True
		for i in range(k):
			s += input()
		for i in s:
			if i not in map:
				map[i] = 1
			else:
				map[i] += 1
		for i in map:
			if map[i] % k != 0:
				possible = False
		if possible:
			print('YES')
		else:
			print('NO')

def Panoramixsprediction():
	nm = input().split(' ')
	n = int(nm[0])
	m = int(nm[1])
	first = True
	for i in range(n + 1, m):
		count = 0
		for j in range(2, i):
			if i % j == 0:
				count += 1
		if count == 0:
			first = False
			break
	if first:
		count = 0
		for j in range(2, m):
			if m % j == 0:
				count += 1
		if count == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')

def ThreepilesofCanides():
	k = int(input())
	for i in range(k):
		n = input().split(' ')
		canides = 0
		for i in n:
			canides += int(i)
		if canides % 2 != 0:
			canides -= 1
		print(canides // 2)

def filename():
	n = int(input())
	name = input()
	more = 0
	map = {}
	map[more] = 0
	count = 0
	for i in name:
		if i == 'x':
			map[more] += 1
		elif map[more] != 0:
			more += 1
			map[more] = 0
	for i in map:
		if map[i] >= 3:
			while map[i] > 2:
				map[i] -= 1
				count += 1
	print(count)

def Football():
	map = {}
	current = 0
	s = input()
	f = s[0]
	map[current] = 0
	check = False
	for i in s:
		if i == f:
			map[current] += 1
		else:
			current += 1
			map[current] = 1
			f = i
	for i in map:
		if map[i] >= 7:
			check = True
	if check:
		print('YES')
	else:
		print('NO')

def CombinationLock1():
	n = int(input())
	fl = input()
	sl = input()
	count = 0
	for i in range(n):
		goup = int(fl[i])
		god = int(fl[i])
		cu = 0
		cd = 0
		keep = True
		while keep:
			if goup + 1 <= 9:
				goup += 1
				cu += 1
			else:
				goup = 0
				cu += 1
			if god - 1 >= 0:
				god -= 1
				cd += 1
			else:
				god = 9
				cd += 1
			if goup == int(sl[i]):
				count += cu
				keep = False
			elif god == int(sl[i]):
				count += cd
				keep = False
	print(count)

def Watermelon():
	n = int(input())
	down = n // 2
	up = n - down
	rge = up
	for i in range(rge):
		if up % 2 == 0 and down % 2 == 0:
			return print('YES')
		elif up + 1 < n and down - 1 > 0:
			up += 1
			down -= 1
		else:
			return print('NO')

def Dominopiling():
	nk = input().split(' ')
	n = int(nk[0])
	k = int(nk[1])
	mnk = n * k
	print(mnk // 2)

def yetanotherBookshelf():
	n = int(input())
	for i in range(n):
		le = int(input())
		K = input().split(' ')
		SK = []
		lili = []
		for i in range(le):
			if i + 1 <= le - 1:
				if K[i] == '1' and K[i + 1] == '1':
					lili.append(i)
		lili.reverse()
		for i in lili:
			K.pop(i)
		coun = 0
		while K.count('1') > 1:
			f = K.index('1')
			K.pop(f)
			K.insert(f + 1, '1')
			f += 1
			if K[f + 1] == '1':
				K.pop(f)
			coun += 1
		print(coun)

def Combinationlockittakestolong():
	n = int(input())
	fl = input()
	sl = input()
	counter = 0
	for i in range(n):
		up = int(fl[i])
		down = int(fl[i])
		while True:
			if up + 1 <= 9:
				up += 1
			else:
				up = 0
			if down - 1 >= 0:
				down -= 1
			else:
				down = 9
			counter += 1
			if up == int(sl) or down == int(sl):
				break

def iwannabetheguytolong():
	n = int(input())
	lvl = input().split(' ')
	lvls = input().split(' ')
	for i in range(1, n + 1):
		if str(i) not in lvl and str(i) not in lvls:
			return print('Oh, my keyboard!')
	return print('I become the guy.')

def giftsettolong():
	n = int(input())
	for i in range(n):
		rb = input().split(' ')
		x = int(rb[0])
		y = int(rb[1])
		a = int(rb[2])
		b = int(rb[3])
		giftset = 0
		while True:
			if x - a >= 0 and y - b >= 0:
				x -= a
				y -= b
				giftset += 1
			elif x - b >= 0 and y - a >= 0:
				x -= b
				y -= a
				giftset += 1
			else:
				break
		print(giftset)

def uniquwbidauctiontime():
	n = int(input())
	for i in range(n):
		k = int(input())
		list = input().split(' ')
		o = -1
		for i in range(k):
			if list.count(list[i]) == 1:
				if o == -1 or list[i] < o:
					o = list[i]
		if o != -1:
			print(list.index(o) + 1)
		else:
			print(o)

def equalizepriceagain():
	n = int(input())
	for i in range(n):
		k = int(input())
		numbers = input().split(' ')
		for i in range(len(numbers)):
			numbers[i] = int(numbers[i])
		total = 0
		for i in numbers:
			total += i
		if total % k == 0:
			print(total // k)
		else:
			while total % k != 0:
				total += 1
			print(total // k)

def shortsubstrings():
	n = int(input())
	for i in range(n):
		s = input()
		laist = []
		for i in range(len(s)):
			if i % 2 != 0 and i != len(s) - 1:
				laist.append(i)
		laist.reverse()
		s = list(s)
		for i in laist:
			s.pop(i)
		sa = ''
		for i in s:
			sa += i
		print(sa)

def policerecruits():
	n = int(input())
	k = input().split(' ')
	officers = 0
	crimes = 0
	for i in k:
		if int(i) == -1:
			if officers == 0:
				crimes += 1
			else:
				officers -= 1
		else:
			officers += int(i)
	print(crimes)

def thenewyear():
	xxx = input().split(' ')
	for i in range(len(xxx)):
		xxx[i] = int(xxx[i])
	xxx.sort()
	way = 0
	way += abs(int(xxx[1]) - int(xxx[0]))
	way += abs(int(xxx[1]) - int(xxx[2]))
	print(way)

def frogjumpingtimelimit():
	n = int(input())
	for i in range(n):
		abk = input().split(' ')
		a = int(abk[0])
		b = int(abk[1])
		k = int(abk[2])
		all = 0
		for i in range(k):
			if i % 2 == 0:
				all += a
			else:
				all -= b
		print(all)

def patrickandshopping():
	d = input().split(' ')
	d3 = 0
	for i in range(len(d)):
		if int(d[i]) > d3:
			d3 = int(d[i])
	d.pop(d.index(str(d3)))
	d1 = int(d[0])
	d2 = int(d[1])
	distance = d1 + d2
	if d3 <= distance:
		distance += d3
	else:
		distance += distance
	print(distance)

def Freeicecream():
	nx = input().split(' ')
	n = int(nx[0])
	ice = int(nx[1])
	diskid = 0
	for i in range(n):
		k = input().split(' ')
		if k[0] == '+':
			ice += int(k[1])
		elif ice >= int(k[1]):
			ice -= int(k[1])
		else:
			diskid += 1
	print(ice, diskid)

def Reviewsite():
	t = int(input())
	for i in range(t):
		n = int(input())
		upvotes = 0
		votes = input().split(' ')
		for i in votes:
			if i != '2':
				upvotes += 1
		print(upvotes)

def Lastyeasrtssubstring():
	t = int(input())
	for i in range(t):
		n = int(input())
		s = input()
		if s[0:4] == '2020' or s[n - 4:n] == '2020':
			print('YES')
		elif s[0:3] == '202' and s[n - 1] == '0':
			print('YES')
		elif s[n - 3:n] == '020' and s[0] == '2':
			print('YES')
		elif s[0:2] == '20' and s[n - 2] == '20':
			print('YES')
		elif s[n - 2:n] == '20' and s[0:2] == '20':
			print('YES')
		else:
			print('NO')

def Arena():
	t = int(input())
	for i in range(t):
		n = int(input())
		heros = input().split(' ')
		heorsint = [int(i) for i in heros]
		heorsint.sort()
		min = heorsint[0]
		winner = n - heorsint.count(min)
		print(winner)

def twoRabbitstoolongbutright():
	t = int(input())
	for i in range(t):
		xyab = input().split(' ')
		x = int(xyab[0])
		y = int(xyab[1])
		a = int(xyab[2])
		b = int(xyab[3])
		seconds = 0
		while x < y:
			x += a
			y -= b
			seconds += 1
		if x == y:
			print(seconds)
		else:
			print(-1)

def systemofequations():
	nm = input().split(' ')
	n = int(nm[0])
	m = int(nm[1])
	nm = [int(i) for i in nm]
	nm.sort()
	count = 0
	for i in range(nm[0] + 1):
		for j in range(nm[0] + 1):
			if i ** 2 + j == n and j ** 2 + i == m:
				count += 1
	print(count)

def polycarpwspockets():
	n = int(input())
	coins = input().split(' ')
	coins = [int(i) for i in coins]
	pocket = 0
	for i in coins:
		nmumbver = coins.count(i)
		if nmumbver > pocket:
			pocket = nmumbver
	print(pocket)

def repeaqtijgcipher():
	n = int(input())
	s = input()
	counter = 0
	rep = 1
	ns = ''
	while counter < n:
		counter += rep
		ns += s[counter - 1]
		rep += 1
	print(ns)

def Neaarestinterestingnumber():
	a = input()
	s = int(a)
	while True:
		if sum((int(i) for i in str(s))) % 4 == 0:
			return print(s)
		else:
			s += 1

def therearetwotzpesofburgers():
	t = int(input())
	for i in range(t):
		ess = input().split(' ')
		ess = [int(i) for i in ess]
		price = input().split(' ')
		buns = int(ess[0])
		totalmoney = 0
		first = True
		if int(price[0]) > int(price[1]):
			patties = ess[1]
			otherpatties = ess[2]
			money = int(price[0])
			othermoney = int(price[1])
		else:
			patties = ess[2]
			otherpatties = ess[1]
			money = int(price[1])
			othermoney = int(price[0])
		keep = True
		while keep:
			if buns - 2 >= 0 and patties - 1 >= 0:
				buns -= 2
				patties -= 1
				totalmoney += money
			elif buns - 2 >= 0 and patties == 0:
				if first:
					patties = otherpatties
					money = othermoney
					first = False
				else:
					print(totalmoney)
					keep = False
			else:
				print(totalmoney)
				keep = False

def threeswimmerstimelimitebutseemsright():
	t = int(input())
	for i in range(t):
		pabc = input().split(' ')
		pabc = [int(i) for i in pabc]
		a = 0
		b = 0
		c = 0
		p = pabc[0]
		keep = True
		while keep:
			if a < p:
				a += pabc[1]
			if b < p:
				b += pabc[2]
			if c < p:
				c += pabc[3]
			if a >= p and b >= p and (c >= p):
				list = [a - p, b - p, c - p]
				list.sort()
				print(list[0])
				keep = False

def Gregsworkout():
	n = int(input())
	training = input().split(' ')
	training = [int(i) for i in training]
	map = [0, 0, 0]
	current = 0
	for i in training:
		map[current] += i
		if current < 2:
			current += 1
		else:
			current = 0
	sorte = []
	for i in map:
		sorte.append(i)
	sorte.sort()
	index = map.index(sorte[2])
	if index == 0:
		print('chest')
	elif index == 1:
		print('biceps')
	else:
		print('back')

def heisttimelimitebutseemsright():
	n = int(input())
	all = input().split(' ')
	all = [int(i) for i in all]
	all.sort()
	counter = 0
	for i in range(all[0], all[len(all) - 1]):
		if i not in all:
			counter += 1
	print(counter)

def nonzero():
	t = int(input())
	for i in range(t):
		n = int(input())
		numbers = input().split(' ')
		count = numbers.count('0')
		for i in range(count):
			ind = numbers.index('0')
			numbers.pop(ind)
			numbers.insert(ind, '1')
		numbers = [int(i) for i in numbers]
		if sum(numbers) == 0:
			count += 1
		print(count)

def distinctdigits():
	lr = input().split(' ')
	for i in range(int(lr[0]), int(lr[1]) + 1):
		couynt = []
		for j in str(i):
			if j not in couynt:
				couynt.append(j)
		if len(couynt) == len(str(i)):
			return print(i)
	else:
		return print(-1)

def dawidandbagsofcandies():
	bags = input().split(' ')
	bags = [int(i) for i in bags]
	bags.sort()
	if bags[0] + bags[3] == bags[1] + bags[2]:
		print('YES')
	elif bags[3] == bags[0] + bags[1] + bags[2]:
		print('YES')
	else:
		print('NO')

def lastminuteenhancements():
	t = int(input())
	for i in range(t):
		n = int(input())
		notes = input().split(' ')
		lists = []
		for i in notes:
			if int(i) not in lists:
				lists.append(int(i))
			elif int(i) + 1 not in lists:
				lists.append(int(i) + 1)
		print(len(lists))

def Cakeminator():
	rc = input().split(' ')
	cake = []
	pices = 0
	rows = 0
	for i in range(int(rc[0])):
		cake.append([i for i in input()])
	for i in range(int(rc[1])):
		count = 0
		for j in range(int(rc[0])):
			if cake[j][i] == '.':
				count += 1
			if count == int(rc[0]):
				pices += count
				rows += 1
	for i in range(int(rc[0])):
		if 'S' not in cake[i]:
			pices += int(rc[1]) - rows
	print(pices)

def CME():
	t = int(input())
	for i in range(t):
		n = int(input())
		four = 4
		while four < n:
			four += 2
		print(four - n)

def FriendsandCandies():
	t = int(input())
	for i in range(t):
		n = int(input())
		cadies = input().split(' ')
		cadies = [int(i) for i in cadies]
		all = sum(cadies) % n
		count = 0
		if all != 0:
			print(-1)
		else:
			for i in cadies:
				if i > sum(cadies) // n:
					count += 1
			print(count)

def tworivalstudents():
	t = int(input())
	for i in range(t):
		nxab = input().split(' ')
		n = int(nxab[0])
		x = int(nxab[1])
		if int(nxab[2]) >= int(nxab[3]):
			bigger = int(nxab[2])
			smaller = int(nxab[3])
		else:
			bigger = int(nxab[3])
			smaller = int(nxab[2])
		for i in range(x):
			if bigger < n:
				bigger += 1
			elif smaller > 1:
				smaller -= 1
			else:
				break
		print(bigger - smaller)

def OmkarandPassword():
	t = int(input())
	for i in range(t):
		n = int(input())
		array = input().split(' ')
		array = [int(i) for i in array]
		pointer = 0
		while array.count(array[0]) != len(array):
			if array[pointer] != array[pointer + 1]:
				array.insert(pointer, array[pointer] + array[pointer + 1])
				array.pop(pointer)
				array.pop(pointer + 1)
			elif pointer + 1 < len(array) - 1:
				pointer += 1
			else:
				pointer = 0
		print(len(array))

def tanyaasndstairways():
	n = int(input())
	k = input().split(' ')
	k = [int(i) for i in k]
	last = []
	storeys = k.count(1)
	for i in range(n - 1):
		if k[i] >= k[i + 1]:
			last.append(k[i])
	last.append(k[n - 1])
	print(storeys)
	printable = ''
	for i in last:
		printable += str(i) + ' '
	print(printable)

def adjacentreplacements():
	t = int(input())
	wowowo = input()
	wo = wowowo.split(' ')
	wo = [int(i) for i in wo]
	for i in range(t):
		if wo[i] % 2 == 0:
			wo[i] -= 1
	s = ''
	for i in wo:
		s += str(i) + ' '
	print(s)

def Divideit():
	t = int(input())
	for i in range(t):
		n = int(input())
		counter = 0
		while n > 1:
			if n % 2 == 0:
				n = n // 2
				counter += 1
			elif n % 3 == 0:
				n = 2 * n // 3
				counter += 1
			elif n % 5 == 0:
				n = 4 * n // 5
				counter += 1
			else:
				counter = -1
				break
		print(counter)

def DiverseTeam():
	nk = input().split(' ')
	n = int(nk[0])
	k = int(nk[1])
	rating = input().split(' ')
	list = []
	s = ''
	for i in range(n):
		if rating[i] not in list:
			list.append(rating[i])
			s += str(i + 1) + ' '
		if len(list) == k:
			print('YES')
			return print(s)
	return print('NO')

def phoenixandgold():
	t = int(input())
	for i in range(t):
		nx = input().split(' ')
		n = int(nx[0])
		x = int(nx[1])
		gold = input().split(' ')
		gold = [int(i) for i in gold]
		count = 0
		s = ''
		if sum(gold) == x:
			print('NO')
		else:
			while len(gold) != 0:
				for i in range(len(gold)):
					if i < len(gold):
						if gold[i] + count != x:
							count += gold[i]
							s += str(gold[i]) + ' '
							gold.pop(i)
			print('YES')
			print(s)

def ingamechat():
	t = int(input())
	for i in range(t):
		n = int(input())
		s = input()
		c = 0
		for i in s:
			if i == ')':
				c += 1
			else:
				c = 0
		if c > n - c:
			print('Yes')
		else:
			print('No')

def IntegerSAequencedividing():
	list = [int(i) for i in range(1, int(input()) + 1)]
	list.reverse()
	A = 0
	B = 0
	while len(list) > 0:
		if len(list) != 1:
			one = list[0]
			two = list[1]
			list.pop(0)
			list.pop(0)
		else:
			one = list[0]
			list.pop(0)
			two = 0
		if abs(A + one - (B + two) <= abs(B + one - (A + two))):
			A += one
			B += two
		else:
			A += two
			B += one
	print(abs(A - B))

def shortestpathwithobstacle():
	t = int(input())
	for i in range(t):
		s = input()
		A = [int(i) for i in input().split(' ')]
		B = [int(i) for i in input().split(' ')]
		F = [int(i) for i in input().split(' ')]
		distance = abs(A[0] - B[0]) + abs(A[1] - B[1])
		if A[0] == B[0] and A[0] == F[0] and (min(A[1], B[1]) < F[1]) and (F[1] < max(A[1], B[1])) or (A[1] == B[1] and A[1] == F[1] and (min(A[0], B[0]) < F[0]) and (F[0] < max(A[0], B[0]))):
			distance += 2
		print(distance)

def Removeduplicates():
	t = int(input())
	numbers = input().split(' ')
	numbers.reverse()
	removed = []
	for i in numbers:
		if i not in removed:
			removed.append(i)
	removed.reverse()
	s = ''
	for i in removed:
		s += i + ' '
	print(len(removed))
	print(s)

def Threestrings():
	t = int(input())
	for i in range(t):
		a = input()
		b = input()
		c = input()
		work = True
		for i in range(len(a)):
			if a[i] != c[i] and b[i] != c[i]:
				work = False
		if work:
			print('YES')
		else:
			print('NO')

def specifictastesofandre():
	t = int(input())
	for i in range(t):
		li = [1 for i in range(int(input()))]
		s = ''
		for i in li:
			s += str(i) + ' '
		print(s)

def dejavu():
	t = int(input())
	for i in range(t):
		s = input()
		if s + 'a' == 'a' + s:
			print('NO')
		else:
			sl = list(s + 'a')
			rsl = []
			for i in sl:
				rsl.insert(0, i)
			if sl != rsl:
				print('YES')
				print(s + 'a')
			else:
				print('YES')
				print('a' + s)

def buythestring():
	t = int(input())
	for i in range(t):
		ncch = [int(i) for i in input().split(' ')]
		s = input()
		money = 0
		for i in s:
			if i == '0':
				money += min(ncch[1], ncch[2] + ncch[3])
			else:
				money += min(ncch[2], ncch[1] + ncch[3])
		print(money)

def Keyraces():
	svvtt = [int(i) for i in input().split(' ')]
	first = 2 * svvtt[3] + svvtt[0] * svvtt[1]
	scond = 2 * svvtt[4] + svvtt[0] * svvtt[2]
	if first > scond:
		print('Second')
	elif first < scond:
		print('First')
	else:
		print('Friendship')

def Angrystudents():
	t = int(input())
	for i in range(t):
		len = int(input())
		s = list(input())
		counter = 0
		counterlist = [0]
		if s.count('A') != 0:
			firstp = s.index('A')
			for i in range(firstp, len):
				if s[i] == 'P':
					counter += 1
				else:
					counterlist.append(counter)
					counter = 0
			counterlist.append(counter)
		print(max(counterlist))

def Frence():
	t = int(input())
	for i in range(t):
		d = sum([int(i) for i in input().split(' ')]) - 1
		print(d)

def playongwhithdice():
	ab = [int(i) for i in input().split(' ')]
	a = ab[0]
	b = ab[1]
	awins = 0
	draw = 0
	bwins = 0
	for i in range(1, 7):
		if abs(i - a) < abs(i - b):
			awins += 1
		elif abs(i - a) > abs(i - b):
			bwins += 1
		else:
			draw += 1
	print(awins, draw, bwins)

def arrayandpeaks():
	t = int(input())
	for i in range(t):
		(n, k) = [int(i) for i in input().split(' ')]
		listaa = [i for i in range(1, n - k + 1)]
		listoo = [i for i in range(n - k + 1, n + 1)]
		s = ''
		if len(listaa) > len(listoo):
			for i in range(len(listaa)):
				s += str(listaa[0]) + ' '
				listaa.pop(0)
				if len(listoo) != 0:
					s += str(listoo[0]) + ' '
					listoo.pop(0)
		else:
			s = '-1'
		print(s)

def mishkaandContest():
	(n, k) = [int(i) for i in input().split()]
	problems = [int(i) for i in input().split()]
	fp = 0
	sp = 0
	first = True
	for i in problems:
		if i <= k and first:
			fp += 1
		elif i > k and first:
			first = False
		elif i <= k and (not first):
			sp += 1
		else:
			sp = 0
	print(sp + fp)

def gotanygrapes():
	xyz = [int(i) for i in input().split(' ')]
	abc = [int(i) for i in input().split(' ')]
	c = 0
	for i in range(3):
		c += abc[i]
		c -= xyz[i]
		if c < 0:
			return print('NO')
	return print('YES')

def stringgenerations():
	t = int(input())
	ABC = ['a', 'b', 'c']
	for i in range(t):
		s = ''
		(n, k) = input().split(' ')
		for i in range(int(n)):
			s += ABC[i % 3]
		print(s)

def gradeallocation():
	t = int(input())
	for i in range(t):
		(n, m) = [int(i) for i in input().split(' ')]
		scores = [int(i) for i in input().split(' ')]
		summa = sum(scores)
		if summa >= m:
			print(m)
		else:
			print(summa)

def shashaandsticks():
	(n, k) = [int(i) for i in input().split(' ')]
	counter = n // k
	if counter % 2 == 0:
		print('NO')
	else:
		print('YES')

def Hoteliero():
	n = int(input())
	s = []
	for i in input():
		s.append(i)
	rooms = [0 for i in range(10)]
	for i in s:
		if i == 'L':
			index = rooms.index(0)
			rooms[index] = 1
		elif i == 'R':
			rooms.reverse()
			index = rooms.index(0)
			rooms[index] = 1
			rooms.reverse()
		else:
			index = int(i)
			rooms[index] = 0
	f = ''
	for i in rooms:
		f += str(i)
	print(f)

def barrels():
	t = int(input())
	for i in range(t):
		(n, k) = [int(i) for i in input().split(' ')]
		barrels = [int(i) for i in input().split(' ')]
		maxbarrelcount = barrels.pop(barrels.index(max(barrels)))
		for i in range(k):
			maxbarrelindex = barrels.index(max(barrels))
			maxbarrelcount += barrels[maxbarrelindex]
			barrels.pop(maxbarrelindex)
		print(maxbarrelcount)

def lovetriangle():
	n = int(input())
	planes = [int(i) - 1 for i in input().split(' ')]
	for i in range(n):
		if planes[planes[planes[i]]] == i:
			return print('YES')
	return print('NO')

def lovesong():
	(n, q) = [int(i) for i in input().split(' ')]
	s = input()
	for i in range(q):
		(l, r) = [int(i) for i in input().split(' ')]
		l -= 1
		substr = s[l:r]
		c = 0
		for i in substr:
			c += string.ascii_lowercase.index(i) + 1
		print(c)

def coins():
	(n, S) = [int(i) for i in input().split(' ')]
	if S % n == 0:
		print(S // n)
	else:
		print(S // n + 1)

def penandpencils9():
	t = int(input())
	for i in range(t):
		(a, b, c, d, k) = [int(i) for i in input().split(' ')]
		(x, y) = (0, 0)
		x += a // c
		if a % c != 0:
			x += 1
		y = b // d
		if b % d != 0:
			y += 1
		if y + x <= k:
			print(x, y)
		else:
			print(-1)

def phonenumber():
	t = int(input())
	for i in range(2):
		n = int(input())
		number = input()
		if '8' in number:
			if n - number.index('8') >= 10:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')

def cars():
	n = int(input())
	cards = [int(i) for i in input().split(' ')]
	playercount = n // 2
	eachplayer = sum(cards) // playercount
	for i in range(n):
		if cards[i] != 0:
			x = cards[i]
			cards.pop(i)
			cards.insert(i, 0)
			y = cards.index(eachplayer - x)
			cards.pop(y)
			cards.insert(y, 0)
			print(i + 1, y + 1)
cars()


def give_cards(n, cards):
	result = []
	cards_copy = cards[:]
	for i in range(1, n):
		sum = cards_copy[0][1] + cards_copy[i][1]
		if cards_copy[0][1] >= cards_copy[i][1]:
			result.append([1, i + 1])
		else:
			result.append([i + 1, 1])
		cards_copy.pop(0)
		cards_copy.pop(i - 1)
		j = 1
		while cards_copy and j <= len(cards_copy) - 1:
			if cards_copy[0][1] + cards_copy[j][1] == sum:
				if cards_copy[0][1] >= cards_copy[j][1]:
					result.append([cards_copy[0][0], cards_copy[j][0]])
				elif cards_copy[0][1] < cards_copy[j][1]:
					result.append([cards_copy[j][0], cards_copy[0][0]])
				cards_copy.pop(0)
				cards_copy.pop(j - 1)
				j = 1
			else:
				j += 1
		if cards_copy:
			result = []
			cards_copy = cards[:]
		else:
			break
	return result
n = int(input())
cards = list([int(i) for i in input().split(' ')])
enum_cards = []
for i in range(1, n + 1):
	enum_cards.append([i, cards[i - 1]])
for (first, second) in give_cards(n, enum_cards):
	print(first, second)


n = int(input())
a = input().split(' ')
b = []
for i in range(n):
	b.append(i)
for i in range(n - 1):
	for j in range(n - i - 1):
		if int(a[j]) > int(a[j + 1]):
			(a[j], a[j + 1]) = (a[j + 1], a[j])
			(b[j], b[j + 1]) = (b[j + 1], b[j])
for i in range(0, n // 2):
	print(str(b[i] + 1) + ' ' + str(b[n - 1 - i] + 1))