You are given an array $a$ consisting of $n$ integers. You can perform the following operations arbitrary number of times (possibly, zero):

  Choose a pair of indices $(i, j)$ such that $|i-j|=1$ (indices $i$ and $j$ are adjacent) and set $a_i := a_i + |a_i - a_j|$;  Choose a pair of indices $(i, j)$ such that $|i-j|=1$ (indices $i$ and $j$ are adjacent) and set $a_i := a_i - |a_i - a_j|$. 

The value $|x|$ means the absolute value of $x$. For example, $|4| = 4$, $|-3| = 3$.

Your task is to find the minimum number of operations required to obtain the array of equal elements and print the order of operations to do it.

It is guaranteed that you always can obtain the array of equal elements using such operations.

Note that after each operation each element of the current array should not exceed $10^{18}$ by absolute value.


-----Input-----

The first line of the input contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of elements in $a$.

The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($0 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.


-----Output-----

In the first line print one integer $k$ — the minimum number of operations required to obtain the array of equal elements.

In the next $k$ lines print operations itself. The $p$-th operation should be printed as a triple of integers $(t_p, i_p, j_p)$, where $t_p$ is either $1$ or $2$ ($1$ means that you perform the operation of the first type, and $2$ means that you perform the operation of the second type), and $i_p$ and $j_p$ are indices of adjacent elements of the array such that $1 \le i_p, j_p \le n$, $|i_p - j_p| = 1$. See the examples for better understanding.

Note that after each operation each element of the current array should not exceed $10^{18}$ by absolute value.

If there are many possible answers, you can print any.


-----Examples-----
Input
5
2 4 6 6 6

Output
2
1 2 3 
1 1 2 

Input
3
2 8 10

Output
2
2 2 1 
2 3 2 

Input
4
1 1 1 1

Output
0

Source: codeforces | Difficulty: MEDIUM
Tags: Greedy algorithms

Constructive algorithms


Solutions:
from copy import deepcopy
from collections import Counter

def find_target(a, n):
	ca = Counter(deepcopy(a))
	val = list(sorted(ca.keys(), key=lambda x: ca[x]))[-1]
	for i in range(n):
		if a[i] == val:
			return i

def solve(a, ind, n):
	res = []
	for i in range(ind + 1, n):
		if a[i] > a[i - 1]:
			res.append((2, i + 1, i))
		elif a[i] < a[i - 1]:
			res.append((1, i + 1, i))
		a[i] = a[ind]
	for i in range(ind - 1, -1, -1):
		if a[i] > a[i + 1]:
			res.append((2, i + 1, i + 2))
		elif a[i] < a[i + 1]:
			res.append((1, i + 1, i + 2))
		a[i] = a[ind]
	return res

def show(res):
	print(len(res))
	for (op, i, j) in res:
		print(op, i, j)

def main():
	n = int(input())
	a = list(map(int, input().split()))
	show(solve(a, find_target(a, n), n))
main()


from collections import *
(n, a) = (int(input()), list(map(int, input().split())))
mem = Counter(a)
(ma, ans) = (max(mem, key=mem.get), [])
for i in range(n):
	if a[i] == ma:
		for j in range(i + 1, n):
			if a[j] != ma:
				ans.append([1, j + 1, j] if a[j] < a[j - 1] else [2, j + 1, j])
				a[j] = ma
			else:
				break
		for j in range(i - 1, -1, -1):
			if a[j] != ma:
				ans.append([1, j + 1, j + 2] if a[j] < a[j + 1] else [2, j + 1, j + 2])
				a[j] = ma
			else:
				break
print(len(ans))
for i in ans:
	print(*i)


import sys
import statistics

def most_frequent(List):
	dict = {}
	(count, itm) = (0, '')
	for item in reversed(List):
		dict[item] = dict.get(item, 0) + 1
		if dict[item] >= count:
			(count, itm) = (dict[item], item)
	return (count, itm)
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split(' ')))
(m, pivot) = most_frequent(a)
start = -1
intervals = []
count = 0
for i in range(len(a)):
	if pivot != a[i]:
		count = count + 1
		if start == -1:
			start = i
	else:
		if start != -1:
			intervals.append((start, i - 1))
		start = -1
if start != -1:
	intervals.append((start, len(a) - 1))
print(count)
for (left, right) in intervals:
	if left != 0:
		for i in range(left, right + 1):
			if a[i] < pivot:
				print(1, i + 1, i)
			else:
				print(2, i + 1, i)
	else:
		for i in reversed(range(left, right + 1)):
			if a[i] < pivot:
				print(1, i + 1, i + 2)
			else:
				print(2, i + 1, i + 2)


from __future__ import division, print_function
import io
import os
import sys
from collections import Counter
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from cStringIO import StringIO
	from future_builtins import ascii, filter, hex, map, oct, zip
else:
	from io import BytesIO as StringIO
(sys.stdout, stream) = (io.IOBase(), StringIO())
sys.stdout.flush = lambda : os.write(1, stream.getvalue()) and (not stream.truncate(0)) and stream.seek(0)
sys.stdout.write = stream.write if sys.version_info[0] < 3 else lambda s: stream.write(s.encode())
(input, flush) = (sys.stdin.readline, sys.stdout.flush)
input = StringIO(os.read(0, os.fstat(0).st_size)).readline

def main():
	n = int(input())
	a = list(map(int, input().split()))
	(m, mc) = Counter(a).most_common(1)[0]
	mi = a.index(m)
	print(n - mc)
	for i in range(mi - 1, -1, -1):
		print(1 if a[i] < m else 2, i + 1, i + 2)
	for i in range(mi, n):
		if a[i] != m:
			print(1 if a[i] < m else 2, i + 1, i)
main()


amount = int(input())
array = [int(s) for s in input().split()]
counter = [0] * (2 * 10 ** 5 + 1)
for i in range(len(array)):
	counter[array[i]] += 1
idx = -1
max_counter = -1
for i in range(len(counter)):
	if counter[i] > max_counter:
		max_counter = counter[i]
		idx = i
indices = []
for i in range(len(array)):
	if array[i] == idx:
		indices.append(i)
print(len(array) - len(indices))
if indices[0] != 0:
	indices.insert(0, 0)
ans = ''
for i in range(1, len(indices)):
	for j in range(indices[i], indices[i - 1], -1):
		if idx > array[j - 1]:
			ans += '1' + ' ' + str(j) + ' ' + str(j + 1) + '\n'
		elif idx < array[j - 1]:
			ans += '2' + ' ' + str(j) + ' ' + str(j + 1) + '\n'
if indices[-1] != len(array) - 1:
	for j in range(indices[-1], len(array) - 1):
		if idx > array[j + 1]:
			ans += '1' + ' ' + str(j + 2) + ' ' + str(j + 1) + '\n'
		elif idx < array[j + 1]:
			ans += '2' + ' ' + str(j + 2) + ' ' + str(j + 1) + '\n'
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
cnt = [0] * 200005
arr = []
for i in a:
	cnt[i] += 1
moves = n - max(cnt)
ele = cnt.index(max(cnt))
idx = a.index(ele)
print(moves)
if moves:
	c = 0
	while c < n:
		if a[c] != ele and c < idx:
			arr.append([[1, 2][a[c] > ele], c + 1, c + 2])
		elif a[c] == ele:
			idx = c
		elif a[c] != ele and c > idx:
			print([1, 2][a[c] > ele], c + 1, c)
		c += 1
	arr = arr[::-1]
	for i in arr:
		print(*i)


n = int(input())
s = list(map(int, input().split()))
cnt = dict()
for x in s:
	if x not in cnt:
		cnt[x] = 1
	else:
		cnt[x] += 1
mx = -1
x = -1
for k in cnt:
	if mx < cnt[k]:
		mx = cnt[k]
		x = k
print(n - mx)
for i in range(s.index(x) - 1, -1, -1):
	if s[i] > x:
		print(2, i + 1, i + 2)
		s[i] = x
	elif s[i] < x:
		print(1, i + 1, i + 2)
		s[i] = x
for j in range(s.index(x) + 1, len(s)):
	if s[j] > x:
		print(2, j + 1, j)
		s[j] = x
	elif s[j] < x:
		print(1, j + 1, j)
		s[j] = x


from collections import Counter, deque
n = int(input())
a = [int(x) for x in input().split()]
c = Counter()
for x in a:
	c[x] += 1
commons = c.most_common(1)
(nKey, count) = commons[0]
count = n - count
q = deque()
for i in range(n):
	if i > 0 and a[i] != nKey and (a[i - 1] == nKey):
		q.append((i, i - 1))
	if i < n - 1 and a[i] != nKey and (a[i + 1] == nKey):
		q.append((i, i + 1))
ops = []
while len(q) > 0:
	(curI, curJ) = q.popleft()
	if a[curI] == nKey:
		continue
	if a[curI] < a[curJ]:
		ops.append((1, curI + 1, curJ + 1))
	else:
		ops.append((2, curI + 1, curJ + 1))
	a[curI] = nKey
	if curI > 0 and a[curI - 1] != nKey:
		q.append((curI - 1, curI))
	if curI < n - 1 and a[curI + 1] != nKey:
		q.append((curI + 1, curI))
print(len(ops))
for x in ops:
	for t in x:
		print(t, end=' ')
	print()


n = int(input())
a = [int(t) for t in input().split(' ')]
numbers = [0] * (max(a) + 1)
for ai in a:
	numbers[ai] += 1
most = max(numbers)
target = numbers.index(most)
ops = n - most
print(ops)
left = 0
while ops:
	try:
		idx = a.index(target, left)
		for i in reversed(range(left, idx)):
			print(1 if a[i] < target else 2, i + 1, i + 2)
			ops -= 1
		left = idx
		while left < len(a) and a[left] == target:
			left += 1
	except ValueError:
		for i in range(left, n):
			print(1 if a[i] < target else 2, i + 1, i)
			ops -= 1


from sys import stdin, exit
from collections import Counter
stdin.readline()
numbers = tuple(map(int, stdin.readline().rstrip().split(' ')))
counter = Counter(numbers)
(mfqn, mfqn_count) = counter.most_common(1)[0]
k = len(numbers) - mfqn_count
print(k)
mfqn_indices = (ind for (ind, number) in enumerate(numbers) if number == mfqn)
prev_mfqn_index = -1
for mfqn_index in mfqn_indices:
	max_ind_to_change = mfqn_index - 1
	min_ind_to_change = prev_mfqn_index + 1
	indices_to_change = tuple((index for index in range(max_ind_to_change, min_ind_to_change - 1, -1) if index >= 0))
	for index in indices_to_change:
		number = numbers[index]
		operation = 1 if number < mfqn else 2
		print(f'{operation} {index + 1} {index + 2}')
	prev_mfqn_index = mfqn_index
min_ind_to_change = mfqn_index + 1
max_ind_to_change = len(numbers) - 1
indices_to_change = filter(lambda index: index < len(numbers), range(min_ind_to_change, max_ind_to_change + 1))
for index in indices_to_change:
	number = numbers[index]
	operation = 1 if number < mfqn else 2
	print(f'{operation} {index + 1} {index}')


n = int(input())
a = list(map(int, input().rstrip().split()))
p = dict()
for i in a:
	if i in p:
		p[i] += 1
	else:
		p[i] = 1
b = list(p.values())
flag = 0
value = 0
index = -1
freq = 0
for i in p:
	if p[i] > freq:
		freq = p[i]
		value = i
if freq > 1:
	flag = 1
index = a.index(value)
count = 0
result = []
if flag == 1:
	if index == 0:
		for i in range(1, len(a)):
			if a[i] < value:
				result.append((1, i, i - 1))
				a[i] = value
			elif a[i] > value:
				result.append((2, i, i - 1))
				a[i] = value
	elif index == n - 1:
		for i in range(n - 1, -1, -1):
			if a[i] < value:
				result.append((1, i, i + 1))
				a[i] = value
			elif a[i] > value:
				result.append((2, i, i + 1))
				a[i] = value
	else:
		for i in range(index - 1, -1, -1):
			if a[i] < value:
				result.append((1, i, i + 1))
				a[i] = value
			elif a[i] > value:
				result.append((2, i, i + 1))
				a[i] = value
		for i in range(index + 1, n):
			if a[i] < value:
				result.append((1, i, i - 1))
				a[i] = value
			elif a[i] > value:
				result.append((2, i, i - 1))
				a[i] = value
if flag == 0:
	value = a[0]
	for i in range(1, n):
		if a[i] < value:
			result.append((1, i, i - 1))
			a[i] = value
		elif a[i] > value:
			result.append((2, i, i - 1))
			a[i] = value
print(len(result))
for i in result:
	print(i[0], i[1] + 1, i[2] + 1)


import os
import heapq
import sys, threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10 ** 5)
from io import BytesIO, IOBase

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

def power(x, p, m):
	res = 1
	while p:
		if p & 1:
			res = res * x % m
		x = x * x % m
		p >>= 1
	return res

def inar():
	return [int(k) for k in input().split()]

def lcm(num1, num2):
	return num1 * num2 // gcd(num1, num2)

def main():
	t = 1
	for _ in range(t):
		n = int(input())
		arr = inar()
		res = []
		dic = defaultdict(int)
		for i in range(n):
			dic[arr[i]] += 1
		dic = dict(sorted(dic.items(), key=operator.itemgetter(1), reverse=True))
		index = 0
		max_el = 0
		for (key, item) in dic.items():
			max_el = key
			break
		for i in range(n):
			if arr[i] == max_el:
				index = i
				break
		for i in range(index - 1, -1, -1):
			diff = abs(arr[i] - arr[i + 1])
			if diff > 0:
				if arr[i] < arr[i + 1]:
					res.append((1, i + 1, i + 2))
				else:
					res.append((2, i + 1, i + 2))
				arr[i] = arr[i + 1]
		for i in range(index + 1, n):
			diff = abs(arr[i] - arr[i - 1])
			if diff > 0:
				if arr[i] < arr[i - 1]:
					res.append((1, i + 1, i))
				else:
					res.append((2, i + 1, i))
				arr[i] = arr[i - 1]
		print(len(res))
		for i in range(len(res)):
			print(*res[i])
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')
main()


from collections import Counter
a = int(input())
nums = list(map(int, input().split(' ')))

def calc(a, nums):
	res = []
	(mostCommon, numMostCommon) = Counter(nums).most_common(1)[0]
	ind = 0
	for (i, e) in enumerate(nums):
		if e == mostCommon:
			ind = i
			break
	for (i, el) in enumerate(nums[:ind][::-1]):
		if el != mostCommon:
			operation = 1 if el < mostCommon else 2
			res.append(str(operation) + ' ' + str(ind - i) + ' ' + str(ind - i + 1))
	for (i, el) in enumerate(nums[ind:]):
		if el != mostCommon:
			operation = 1 if el < mostCommon else 2
			res.append(str(operation) + ' ' + str(ind + i + 1) + ' ' + str(ind + i))
	print(len(res))
	for r in res:
		print(r)
calc(a, nums)


def counter(l, n):
	(maxi, first_index, num) = (0, 0, 0)
	d = {}
	for i in range(n):
		try:
			d[l[i]][0] += 1
		except:
			d[l[i]] = [1, i + 1]
		if d[l[i]][0] > maxi:
			maxi = d[l[i]][0]
			num = l[i]
			first_index = d[l[i]][1]
	return [maxi, first_index, num]
n = int(input())
l = list(map(int, input().split()))
(maxi, first_index, num) = counter(l, n)
print(n - maxi)
for i in range(first_index - 1, 0, -1):
	if l[i - 1] < num:
		print('1', i, i + 1)
	elif l[i - 1] > num:
		print('2', i, i + 1)
for i in range(first_index, n):
	if l[i] < num:
		print('1', i + 1, i)
	elif l[i] > num:
		print('2', i + 1, i)


n = int(input())
a = list(map(int, input().split()))
cnt = [0] * 200001
for x in a:
	cnt[x] += 1
mx = max(cnt)
val = -1
for x in a:
	if cnt[x] == mx:
		val = x
index = -1
for (i, x) in enumerate(a):
	if x == val:
		index = i
		break
answer = []
for i in reversed(range(index)):
	if a[i] > val:
		answer.append((2, i, i + 1))
	elif a[i] < val:
		answer.append((1, i, i + 1))
for i in range(index + 1, n):
	if a[i] > val:
		answer.append((2, i, i - 1))
	elif a[i] < val:
		answer.append((1, i, i - 1))
print(len(answer))
for (a, b, c) in answer:
	print(a, b + 1, c + 1)


def solve(a):
	d = {}
	for i in a:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	m = 0
	elem = 0
	for i in d:
		if d[i] > m:
			m = d[i]
			elem = i
	print(len(a) - m)
	start = -1
	for i in range(len(a)):
		if a[i] == elem:
			start = i
			break
	for i in range(start - 1, -1, -1):
		if a[i] < elem:
			print('1 ' + str(i + 1) + ' ' + str(i + 2))
		else:
			print('2 ' + str(i + 1) + ' ' + str(i + 2))
	for i in range(start + 1, len(a)):
		if a[i] != elem:
			if a[i] < elem:
				print('1 ' + str(i + 1) + ' ' + str(i))
			else:
				print('2 ' + str(i + 1) + ' ' + str(i))
n = int(input())
x = input().split()
a = []
for i in x:
	a.append(int(i))
solve(a)


from collections import defaultdict
n = int(input())
A = list(map(int, input().rstrip().split()))
c = defaultdict(int)
for el in A:
	c[el] += 1
(most_p, most_p_amount) = (0, 0)
for (num, amount) in c.items():
	if amount > most_p_amount:
		most_p = num
		most_p_amount = amount
mode = most_p
first = A.index(mode)
i = first - 1
operations = []
while i >= 0:
	if A[i] < mode:
		operations.append((1, i, i + 1))
	elif A[i] > mode:
		operations.append((2, i, i + 1))
	i -= 1
i = first + 1
while i < n:
	if A[i] < mode:
		operations.append((1, i, i - 1))
	elif A[i] > mode:
		operations.append((2, i, i - 1))
	i += 1
print(len(operations))
for (op, i1, i2) in operations:
	print('{} {} {}'.format(op, i1 + 1, i2 + 1))


from sys import stdin, stdout
import sys
import math
sys.setrecursionlimit(15000)

def find_freq(arr, n):
	freq = [0] * 200001
	for i in arr:
		freq[i] += 1
	max_element = 0
	mx = -float('inf')
	for i in range(len(freq)):
		if freq[i] > mx:
			mx = freq[i]
			max_element = i
	index = 0
	for i in range(len(arr)):
		if arr[i] == max_element:
			index = i
	return index

def find_min(arr, n):
	mn = float('inf')
	index = 0
	for i in range(len(arr)):
		if arr[i] < mn:
			mn = arr[i]
			index = i
	return index

def processing_max(arr, n):
	ans = []
	mx = find_freq(arr, n)
	for i in range(mx - 1, -1, -1):
		if arr[i] < arr[mx]:
			ans.append([1, i + 1, i + 2])
		elif arr[i] > arr[mx]:
			ans.append([2, i + 1, i + 2])
		else:
			continue
	for i in range(mx + 1, n):
		if arr[i] < arr[mx]:
			ans.append([1, i + 1, i])
		elif arr[i] > arr[mx]:
			ans.append([2, i + 1, i])
		else:
			continue
	return ans
n = int(stdin.readline().strip())
arr = list(map(int, stdin.readline().split()))
ans_1 = processing_max(arr, n)
print(len(ans_1))
for i in ans_1:
	print(*i)


import math
import sys

def ii():
	return int(input())

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

def li():
	return list(map(int, input().split()))
n = ii()
d = li()
a = {}
for i in d:
	if i in a:
		a[i] += 1
	else:
		a[i] = 1
m = p = 0
for i in a:
	if a[i] > m:
		m = a[i]
		p = i
op = []
pos = d.index(p)
i = pos - 1
while i >= 0:
	if d[i] < p:
		op.append(f'{1} {i + 1} {i + 2}')
	elif d[i] > p:
		op.append(f'{2} {i + 1} {i + 2}')
	i -= 1
i = pos + 1
while i < n:
	if d[i] < p:
		op.append(f'{1} {i + 1} {i}')
	elif d[i] > p:
		op.append(f'{2} {i + 1} {i}')
	i += 1
print(len(op))
for i in op:
	print(i)


from collections import Counter

def op1(array, i, j):
	array[i] = array[i] + abs(array[i] - array[j])

def op2(array, i, j):
	array[i] = array[i] - abs(array[i] - array[j])
amount = int(input())
sequence = list(map(int, input().split()))
(pivot, hm) = Counter(sequence).most_common(1)[0]
print(amount - hm)
starting = sequence.index(pivot)
i = starting - 1
while i >= 0:
	if sequence[i] > pivot:
		op2(sequence, i, i + 1)
		print(2, i + 1, i + 2)
	if sequence[i] < pivot:
		op1(sequence, i, i + 1)
		print(1, i + 1, i + 2)
	i -= 1
i = starting + 1
while i < len(sequence):
	if sequence[i] > pivot:
		op2(sequence, i, i - 1)
		print(2, i + 1, i)
	if sequence[i] < pivot:
		op1(sequence, i, i - 1)
		print(1, i + 1, i)
	i += 1


n = int(input())
s = [int(x) for x in input().split()]
L = sorted(s)
c = 1
G = []
for i in range(1, len(L)):
	if L[i] == L[i - 1]:
		c = c + 1
	else:
		G.append((c, L[i - 1]))
		c = 1
G.append((c, L[-1]))
tg = -1
tgg = -1
for i in range(0, len(G)):
	if G[i][0] > tgg:
		tgg = G[i][0]
		tg = G[i][1]
print(n - tgg)
ptr = -1
for i in range(0, len(s)):
	if s[i] == tg:
		ptr = i
		break
for i in range(ptr, len(s) - 1):
	if s[i + 1] != tg:
		if tg < s[i + 1]:
			print(2, i + 2, i + 1)
		else:
			print(1, i + 2, i + 1)
for i in range(ptr, 0, -1):
	if s[i - 1] != tg:
		if tg < s[i - 1]:
			print(2, i, i + 1)
		else:
			print(1, i, i + 1)


import sys
n = int(input())
arr = list(map(int, input().split()))
dictionary = dict()
max = 0
maxnum = 0
for i in range(len(arr)):
	try:
		if dictionary[arr[i]]:
			pass
	except:
		dictionary[arr[i]] = []
	dictionary[arr[i]].append(i)
	if max < len(dictionary[arr[i]]):
		max = len(dictionary[arr[i]])
		maxnum = arr[i]
if len(dictionary.keys()) == 1:
	print('0')
	sys.exit()
indexes = dictionary[maxnum]
print(len(arr) - max)
indexes.sort()
i = indexes[0]
while i > 0:
	t = 1
	if arr[i - 1] > maxnum:
		t = 2
	print('{:d} {:d} {:d}'.format(t, i, i + 1))
	i -= 1
for i in range(len(indexes) - 1):
	for j in range(indexes[i] + 1, indexes[i + 1]):
		t = 1
		if arr[j] > maxnum:
			t = 2
		print('{:d} {:d} {:d}'.format(t, j + 1, j))
for i in range(indexes[len(indexes) - 1] + 1, len(arr)):
	t = 1
	if arr[i] > maxnum:
		t = 2
	print('{:d} {:d} {:d}'.format(t, i + 1, i))


input()
arr = [int(x) for x in input().split()]
arr2 = arr + []
arr2.sort()
k = -1
count = 0
max_count = 0
arr2.append(-1)
for i in range(0, len(arr2) - 1):
	count = count + 1
	if arr2[i] != arr2[i + 1]:
		if count > max_count:
			max_count = count
			k = arr2[i]
		count = 0
i = len(arr) - 1
l = []
index = -1
j = 0
while i >= 0:
	if arr[i] != k:
		if i + 1 <= len(arr) - 1 and arr[i + 1] == k:
			index = i
			j = 1
			break
		elif i - 1 >= 0 and arr[i - 1] == k:
			index = i
			break
	i -= 1
if index != -1:
	if j == 0:
		if arr[index] < k:
			l.append([1, index, index - 1])
		else:
			l.append([2, index, index - 1])
	elif arr[index] < k:
		l.append([1, index, index + 1])
	else:
		l.append([2, index, index + 1])
i = len(arr) - 1
i1 = index + 1
i2 = index - 1
i = i1
while i < len(arr):
	if arr[i] != k:
		if k > arr[i]:
			l.append([1, i, i - 1])
		else:
			l.append([2, i, i - 1])
		arr[i] = k
	i += 1
i = i2
while i > -1:
	if arr[i] != k:
		if k > arr[i]:
			l.append([1, i, i + 1])
		else:
			l.append([2, i, i + 1])
		arr[i] = k
	i -= 1
print(len(l))
for ele in l:
	print(ele[0], ele[1] + 1, ele[2] + 1)


import sys
import math
import heapq
import bisect
from collections import defaultdict as dd
f = dd(int)
n = int(input())
l = [int(i) for i in input().split()]
for i in l:
	f[i] += 1
m = 0
x = 0
for i in f:
	if f[i] > x:
		m = i
		x = f[i]
p = l.index(m)
ans = []
for i in range(p, n - 1):
	if l[i + 1] != l[i]:
		if l[i + 1] > l[i]:
			ans.append([2, i + 2, i + 1])
		else:
			ans.append([1, i + 2, i + 1])
		l[i + 1] = l[i]
for i in range(p, 0, -1):
	if l[i - 1] != l[i]:
		if l[i - 1] < l[i]:
			ans.append([1, i, i + 1])
		else:
			ans.append([2, i, i + 1])
		l[i - 1] = l[i]
print(len(ans))
for i in ans:
	print(*i)


n = int(input())
lis = list(map(int, input().split()))
has = [0] * 200002
mx = 0
no = 0
ans = []
nu = 0
for j in range(n):
	i = lis[j]
	has[i] += 1
	if has[i] > mx:
		mx = has[i]
		no = j
		nu = i
i = no - 1
while i >= 0:
	if lis[i] != nu:
		if lis[i] < nu:
			ans.append([1, i + 1, i + 2])
		else:
			ans.append([2, i + 1, i + 2])
	i -= 1
i = no + 1
while i < n:
	if lis[i] != nu:
		if lis[i] < nu:
			ans.append([1, i + 1, i])
		else:
			ans.append([2, i + 1, i])
	i += 1
print(len(ans))
for i in ans:
	print(*i)


n = int(input())
lis = list(map(int, input().split()))
has = [0] * 200002
mm = no = 0
loc = -1
for j in range(n):
	i = lis[j]
	has[i] += 1
	if has[i] > mm:
		mm = has[i]
		no = i
		loc = j
i = loc - 1
ans = []
while i >= 0:
	if lis[i] < no:
		ans.append([1, i + 1, i + 2])
	elif lis[i] > no:
		ans.append([2, i + 1, i + 2])
	i -= 1
i = loc + 1
while i < n:
	if lis[i] > no:
		ans.append([2, i + 1, i])
	elif lis[i] < no:
		ans.append([1, i + 1, i])
	i += 1
print(len(ans))
for i in ans:
	print(*i)


import string, copy

def solution(n, nums):
	counts = {}
	for i in nums:
		if i not in counts:
			counts[i] = 0
		counts[i] += 1
	tmp = [(k, v) for (k, v) in counts.items()]
	tmp.sort(key=lambda x: x[1])
	v = tmp[-1][0]
	steps = len(nums) - nums.count(v)
	print(steps)
	start = nums.index(v)
	for i in range(start + 1, len(nums)):
		if nums[i] == v:
			continue
		elif nums[i] > v:
			print('%d %d %d' % (2, i + 1, i))
		elif nums[i] < v:
			print('%d %d %d' % (1, i + 1, i))
	for i in range(start - 1, -1, -1):
		if nums[i] == v:
			continue
		elif nums[i] > v:
			print('%d %d %d' % (2, i + 1, i + 2))
		elif nums[i] < v:
			print('%d %d %d' % (1, i + 1, i + 2))

def parser():
	n = int(input())
	nums = [int(s) for s in input().split(' ')]
	return (n, nums)

def main():
	args = parser()
	solution(*args)
main()


n = int(input())
arr = [int(x) for x in input().split()]
cnt = list(sorted(arr))
same_val = cnt[0]
same_num = 1
max_same_num = 1
for i in range(1, n):
	if cnt[i] == cnt[i - 1]:
		same_num += 1
	else:
		same_num = 1
	if same_num > max_same_num:
		max_same_num = same_num
		same_val = cnt[i]
index = arr.index(same_val)
print(n - max_same_num)
for i in range(index - 1, -1, -1):
	if arr[i] == same_val:
		continue
	if arr[i] < same_val:
		print(1, i + 1, i + 2)
	if arr[i] > same_val:
		print(2, i + 1, i + 2)
for i in range(index + 1, n):
	if arr[i] == same_val:
		continue
	if arr[i] < same_val:
		print(1, i + 1, i)
	if arr[i] > same_val:
		print(2, i + 1, i)


from collections import deque
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
mycounter = Counter(a).most_common()
ans = []
OO = mycounter[0][0]
MIN_index = a.index(OO)
for i in range(MIN_index - 1, -1, -1):
	if a[i] > OO:
		ans.append([2, i, i + 1])
	elif a[i] < OO:
		ans.append([1, i, i + 1])
for i in range(MIN_index + 1, n):
	if a[i] > OO:
		ans.append([2, i, i - 1])
	elif a[i] < OO:
		ans.append([1, i, i - 1])
print(len(ans))
for (i, j, k) in ans:
	print(i, j + 1, k + 1)


from collections import defaultdict
n = int(input())
arr = list(map(int, input().split()))
d = defaultdict(int)
for i in arr:
	d[i] += 1
cnt = 0
element = 0
for i in d.items():
	if i[1] > cnt:
		cnt = i[1]
		element = i[0]
ans = []
pos = arr.index(element)
for i in range(pos, n):
	if arr[i] == element:
		pass
	elif arr[i] < arr[i - 1]:
		ans.append([1, i + 1, i])
	else:
		ans.append([2, i + 1, i])
	arr[i] = element
for i in range(pos, -1, -1):
	if arr[i] == element:
		pass
	elif arr[i] < arr[i + 1]:
		ans.append([1, i + 1, i + 2])
	else:
		ans.append([2, i + 1, i + 2])
	arr[i] = element
if len(ans):
	print(len(ans))
	for i in ans:
		print(*i)
else:
	print(0)


n = int(input())
a = list(map(int, input().split()))
b = []
for i in a:
	b.append(i)
b.sort()
b.append(-1)
tem = b[0]
ln = 1
ou = 0
i = 1
va = b[0]
for i in range(1, n + 1):
	if b[i] == tem:
		ln += 1
	else:
		if ou < ln:
			ou = ln
			va = b[i - 1]
		ln = 1
		tem = b[i]
print(n - ou)
k = n - ou
i = 0
st = []
while a[i] != va:
	if a[i] < va:
		st.append([1, i, i + 1])
		i += 1
	elif a[i] > va:
		st.append([2, i, i + 1])
		i += 1
for j in range(len(st) - 1, -1, -1):
	print(str(st[j][0]), str(st[j][1] + 1), str(st[j][2] + 1))
for j in range(i + 1, n):
	if a[j] < va:
		print(str(1), str(j + 1), str(j))
	elif a[j] > va:
		print(str(2), str(j + 1), str(j))


from collections import Counter

def Most_Common(lst):
	data = Counter(lst)
	return data.most_common(1)[0][0]

def check(s):
	m = Most_Common(s)
	occ = [int(i == m) for i in s]
	print(len(s) - sum(occ))
	first = occ.index(1)
	for i in range(first):
		if s[first - i - 1] > s[first - i]:
			print(2, first - i - 1 + 1, first - i + 1)
			s[first - i - 1] = s[first - i]
			occ[first - i - 1] = 1
		else:
			print(1, first - i - 1 + 1, first - i + 1)
			s[first - i - 1] = s[first - i]
			occ[first - i - 1] = 1
	for i in range(len(s)):
		if occ[i] == 0:
			if s[i] > s[i - 1]:
				print(2, i + 1, i)
				s[i] = s[i - 1]
			else:
				print(1, i + 1, i)
				s[i] = s[i - 1]
n = int(input())
s = [int(i) for i in input().split()]
check(s)


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

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

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

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

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

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

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

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = Int()
a = array()
C = Counter(a)
b = [(C[i], i) for i in C]
b.sort(reverse=True)
key = b[0][1]
print(n - C[key])
found = 1
ans = []
for i in range(n):
	if key < a[i]:
		ans.append((2, i + 1, i + 1 + found))
	elif key > a[i]:
		ans.append((1, i + 1, i + 1 + found))
	elif found == 1:
		found = -1
		ans = ans[::-1]
for i in ans:
	print(*i)


n = int(input())
Arr = list(map(int, input().split()))
max_stat = 0
num = 0
idx = -1
Stat = [0] * (2 * 10 ** 5 + 3)
for i in range(n):
	Stat[Arr[i]] += 1
	if Stat[Arr[i]] > max_stat:
		max_stat = Stat[Arr[i]]
		num = Arr[i]
		idx = i
k = 0
for el in Arr:
	if el != num:
		k += 1
print(k)
for i in range(idx, n - 1):
	if Arr[i + 1] < Arr[i]:
		print(1, i + 1 + 1, i + 1)
	elif Arr[i + 1] > Arr[i]:
		print(2, i + 1 + 1, i + 1)
	Arr[i + 1] = num
for i in range(idx, 0, -1):
	if Arr[i - 1] < Arr[i]:
		print(1, i - 1 + 1, i + 1)
	elif Arr[i - 1] > Arr[i]:
		print(2, i - 1 + 1, i + 1)
	Arr[i - 1] = num


n = int(input())
nums = list(map(int, input().split()))
sor = sorted(nums)
max_num = 0
max_count = 0
ans = ''
curr = sor[0]
curr_c = 0
for num in sor:
	if num == curr:
		curr_c += 1
	else:
		if curr_c > max_count:
			max_num = curr
			max_count = curr_c
		curr_c = 1
	curr = num
if curr_c > max_count:
	max_num = curr
ind = nums.index(max_num)
if ind > 0:
	for i in range(ind - 1, -1, -1):
		if nums[i] < max_num:
			ans += '1 ' + str(i + 1) + ' ' + str(i + 2) + '\n'
		elif nums[i] > max_num:
			ans += '2 ' + str(i + 1) + ' ' + str(i + 2) + '\n'
for i in range(ind + 1, len(nums)):
	if nums[i] < max_num:
		ans += '1 ' + str(i + 1) + ' ' + str(i) + '\n'
	elif nums[i] > max_num:
		ans += '2 ' + str(i + 1) + ' ' + str(i) + '\n'
print(ans.count('\n'))
print(ans)


n = int(input())
arr = list(map(int, input().split()))
from collections import Counter
count = Counter(arr)
maxx = max(count.values())
target = -1
for key in count:
	if count[key] == maxx:
		target = key
		break
idx = arr.index(target)
print(len(arr) - maxx)
for i in range(idx - 1, -1, -1):
	if arr[i] < target:
		print(1, i + 1, i + 2)
	elif arr[i] > target:
		print(2, i + 1, i + 2)
for i in range(idx + 1, len(arr)):
	if arr[i] < target:
		print(1, i + 1, i)
	elif arr[i] > target:
		print(2, i + 1, i)


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
count = 0
freq = Counter(l)
freq = freq.most_common(1)[0][0]
index = l.index(freq)
ans = []
for i in range(index - 1, -1, -1):
	if l[i] < freq:
		count += 1
		ans.append([1, i + 1, i + 2])
	if l[i] > freq:
		count += 1
		ans.append([2, i + 1, i + 2])
for i in range(index + 1, n):
	if l[i] < freq:
		count += 1
		ans.append([1, i + 1, i])
	if l[i] > freq:
		count += 1
		ans.append([2, i + 1, i])
print(count)
for i in ans:
	print(*i)


n = int(input())
a = list(map(int, input().split()))
dic = {}
maxim = 0
val = 0
for i in a:
	if i not in dic:
		dic[i] = 1
	else:
		dic[i] += 1
	if dic[i] > maxim:
		maxim = dic[i]
for i in dic:
	if dic[i] == maxim:
		val = i
		break
pos = a.index(val)
k = len(a) - maxim
print(k)
for i in range(pos + 1, n):
	if a[i] > a[i - 1]:
		print(2, i + 1, i)
		a[i] = a[i - 1]
	elif a[i] < a[i - 1]:
		print(1, i + 1, i)
		a[i] = a[i - 1]
for i in range(pos - 1, -1, -1):
	if a[i] > a[i + 1]:
		print(2, i + 1, i + 2)
		a[i] = a[i + 1]
	elif a[i] < a[i + 1]:
		print(1, i + 1, i + 2)
		a[i] = a[i + 1]


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	a = list(map(int, input().split()))
	if len(set(a)) == 1:
		print(0)
		return
	d = {}
	for i in range(n):
		if a[i] in d:
			d[a[i]].add(i)
		else:
			d[a[i]] = {i}
	(max_el, length) = (0, 0)
	for k in d:
		if len(d[k]) > length:
			max_el = k
			length = len(d[k])
	cur = list(d[max_el])
	cur.sort()
	cur_ind = cur[0]
	res = []
	for i in range(cur[0] - 1, -1, -1):
		if a[i] > max_el:
			res.append((2, i + 1, cur_ind + 1))
		else:
			res.append((1, i + 1, cur_ind + 1))
		cur_ind -= 1
	cur_ind = cur[0] + 1
	for i in range(cur[0], n):
		if i in d[max_el]:
			cur_ind = i
			continue
		else:
			if a[i] > max_el:
				res.append((2, i + 1, cur_ind + 1))
			else:
				res.append((1, i + 1, cur_ind + 1))
			cur_ind += 1
	print(len(res))
	for k in res:
		print(*k)
main()


n = int(input())
a = [int(_) for _ in input().split()]
freq = {}
for item in a:
	if item in freq:
		freq[item] += 1
	else:
		freq[item] = 1
most_occ = max(freq, key=lambda x: freq[x])
index_center = a.index(most_occ)
print(len(a) - a.count(most_occ))
for i in range(index_center, 0, -1):
	if a[i - 1] < most_occ:
		a[i - 1] = most_occ
		print(1, i, i + 1)
	elif a[i - 1] > most_occ:
		a[i - 1] = most_occ
		print(2, i, i + 1)
for i in range(index_center, n - 1):
	if a[i + 1] > most_occ:
		a[i + 1] = most_occ
		print(2, i + 2, i + 1)
	elif a[i + 1] < most_occ:
		a[i + 1] = most_occ
		print(1, i + 2, i + 1)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

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

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

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions
from collections import deque, defaultdict, OrderedDict
from fractions import Fraction
from decimal import Decimal

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(1):
		n = ri()
		a = ria()
		d = {}
		m = 0
		z = 0
		for i in a:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
			if d[i] > m:
				m = d[i]
				z = i
		print(n - m)
		x = a.index(z)
		for i in range(x - 1, -1, -1):
			if a[i] == z:
				continue
			if a[i] < z:
				print(1, i + 1, i + 2)
			else:
				print(2, i + 1, i + 2)
		for i in range(x + 1, n):
			if a[i] == z:
				continue
			if a[i] < z:
				print(1, i + 1, i)
			else:
				print(2, i + 1, i)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

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

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


from sys import stdin, stdout
import cProfile, math
from collections import Counter, defaultdict
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
fac_warmup = False
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7
import sys

class merge_find:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n
		self.lista = [[_] for _ in range(n)]

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		if self.size[a] < self.size[b]:
			(a, b) = (b, a)
		self.num_sets -= 1
		self.parent[b] = a
		self.size[a] += self.size[b]
		self.lista[a] += self.lista[b]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def primeFactors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def fibonacci_modP(n, MOD):
	if n < 2:
		return 1
	return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD

def factorial_modP_Wilson(n, p):
	if p <= n:
		return 0
	res = p - 1
	for i in range(n + 1, p):
		res = res * cached_fn(InverseEuler, i, p) % p
	return res

def binary(n, digits=20):
	b = bin(n)[2:]
	b = '0' * (20 - len(b)) + b
	return b

def isprime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True
factorial_modP = []

def warm_up_fac(MOD):
	nonlocal factorial_modP, fac_warmup
	if fac_warmup:
		return
	factorial_modP = [1 for _ in range(fac_warmup_size + 1)]
	for i in range(2, fac_warmup_size):
		factorial_modP[i] = factorial_modP[i - 1] * i % MOD
	fac_warmup = True

def InverseEuler(n, MOD):
	return pow(n, MOD - 2, MOD)

def nCr(n, r, MOD):
	nonlocal fac_warmup, factorial_modP
	if not fac_warmup:
		warm_up_fac(MOD)
		fac_warmup = True
	return factorial_modP[n] * (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD) % MOD) % MOD

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def display_2D_list(li):
	for i in li:
		print(i)

def prefix_sum(li):
	sm = 0
	res = []
	for i in li:
		sm += i
		res.append(sm)
	return res

def get_int():
	return int(stdin.readline().strip())

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

def get_list():
	return list(map(int, stdin.readline().split()))
import heapq, itertools
pq = []
entry_finder = {}
REMOVED = '<removed-task>'

def add_task(task, priority=0):
	if task in entry_finder:
		remove_task(task)
	count = next(counter)
	entry = [priority, count, task]
	entry_finder[task] = entry
	heapq.heappush(pq, entry)

def remove_task(task):
	entry = entry_finder.pop(task)
	entry[-1] = REMOVED

def pop_task():
	while pq:
		(priority, count, task) = heapq.heappop(pq)
		if task is not REMOVED:
			del entry_finder[task]
			return task
	raise KeyError('pop from an empty priority queue')
memory = dict()

def clear_cache():
	nonlocal memory
	memory = dict()

def cached_fn(fn, *args):
	nonlocal memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result

def ncr(n, r):
	return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

def binary_serach(i, li):
	fn = lambda x: li[x] - x // i
	x = -1
	b = len(li)
	while b >= 1:
		while b + x < len(li) and fn(b + x) > 0:
			x += b
		b = b // 2
	return x
TestCases = False
testingMode = False
fac_warmup_size = 10 ** 5 + 100
optimiseForReccursion = True
from math import factorial

def main():
	n = get_int()
	li = get_list()
	count = Counter(li)
	j = 0
	res = []
	maxi = -1
	for i in count.keys():
		if count[i] > j:
			j = count[i]
			maxi = i
	encountered = False
	for (i, ele) in enumerate(li):
		if ele != maxi and (not encountered):
			res.append([1 if ele < maxi else 2, i + 1, i + 2])
		elif ele == maxi and (not encountered):
			encountered = True
			res.reverse()
		elif ele != maxi and encountered:
			res.append([1 if ele < maxi else 2, i + 1, i])
	print(len(res))
	for i in res:
		display_list(i)
if TestCases:
	for _ in range(get_int()):
		cProfile.run('main()') if testingMode else main()
else:
	(cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()


import sys
import math

def IO():
	sys.stdin = open('pyinput.txt', 'r')
	sys.stdout = open('pyoutput.txt', 'w')

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

def LCM(a, b):
	return a * (b // GCD(a, b))

def scan(TYPE_1, TYPE_2=0):
	if TYPE_1 == int:
		return map(int, sys.stdin.readline().strip().split())
	elif TYPE_1 == float:
		return map(float, sys.stdin.readline().strip().split())
	elif TYPE_1 == list and TYPE_2 == float:
		return list(map(float, sys.stdin.readline().strip().split()))
	elif TYPE_1 == list and TYPE_2 == int:
		return list(map(int, sys.stdin.readline().strip().split()))
	elif TYPE_1 == str:
		return sys.stdin.readline().strip()
	else:
		print('ERROR!!!!')

def main():
	n = int(scan(str))
	a = scan(list, int)
	mp = {}
	for i in a:
		mp[i] = 0
	mx = 0
	idx = 0
	for i in range(n):
		mp[a[i]] += 1
		if mp[a[i]] > mx:
			mx = mp[a[i]]
			idx = i
	print(n - mx)
	mx = a[idx]
	for i in range(idx + 1, n):
		if a[i] == mx:
			continue
		if a[i] > mx:
			print(2, i + 1, i)
		else:
			print(1, i + 1, i)
	for i in range(idx - 1, -1, -1):
		if a[i] == mx:
			continue
		if a[i] > mx:
			print(2, i + 1, i + 2)
		else:
			print(1, i + 1, i + 2)
main()


n = int(input())
l = list(map(int, input().split()))
dct = {}
for i in range(n):
	if l[i] in dct:
		dct[l[i]].append(i)
	else:
		dct[l[i]] = [i]
a = n - len(dct[l[0]])
num = l[0]
for i in dct:
	if n - len(dct[i]) < a:
		a = n - len(dct[i])
		num = i
prev = -1
print(a)
for x in dct[num]:
	for p in range(x - 1, prev, -1):
		if l[p] < num:
			print(1, p + 1, p + 2)
		else:
			print(2, p + 1, p + 2)
	prev = x
for p in range(prev + 1, n):
	if l[p] < num:
		print(1, p + 1, p)
	else:
		print(2, p + 1, p)


n = int(input())
arr = list(map(int, input().split()))
cnts = [0] * 200001
(best, best_cnt, idx) = (None, 0, None)
for i in range(n):
	cnts[arr[i]] += 1
	if cnts[arr[i]] > best_cnt:
		(best, best_cnt, idx) = (arr[i], cnts[arr[i]], i)
moves = []
for i in range(idx, 0, -1):
	if arr[i - 1] < best:
		moves.append((1, i, i + 1))
	elif arr[i - 1] > best:
		moves.append((2, i, i + 1))
for i in range(idx, n - 1):
	if arr[i + 1] > best:
		moves.append((2, i + 2, i + 1))
	elif arr[i + 1] < best:
		moves.append((1, i + 2, i + 1))
print(len(moves))
for move in moves:
	print(*move)


n = int(input())
a = [int(j) for j in input().split()]
li = [0] * (2 * 10 ** 5 + 1)
for x in a:
	li[x] += 1
ma = 0
for j in range(len(li)):
	if li[j] > ma:
		ma = li[j]
		val = j
print(n - li[val])
for x in range(n):
	if a[x] == val:
		ind = x
for x in range(ind + 1, n):
	if a[x] < val:
		print(1, x + 1, x)
	elif a[x] > val:
		print(2, x + 1, x)
for x in range(ind - 1, -1, -1):
	if a[x] < val:
		print(1, x + 1, x + 2)
	elif a[x] > val:
		print(2, x + 1, x + 2)


def mp():
	return map(int, input().split())
n = int(input())
a = list(mp())
c = [0] * (2 * 10 ** 5 + 1)
for i in a:
	c[i] += 1
idx = 0
for i in range(2 * 10 ** 5 + 1):
	if c[i] > c[idx]:
		idx = i
for i in range(n):
	if a[i] == idx:
		idx = i
		break
ans = []
for i in range(idx - 1, -1, -1):
	if a[i] == a[idx]:
		continue
	if a[i] > a[idx]:
		ans.append([2, i + 1, i + 2])
	else:
		ans.append([1, i + 1, i + 2])
for i in range(idx + 1, n):
	if a[i] == a[idx]:
		continue
	if a[i] > a[idx]:
		ans.append([2, i + 1, i])
	else:
		ans.append([1, i + 1, i])
print(len(ans))
for i in ans:
	print(*i)


from collections import Counter
n = int(input())
numbers = list(map(int, input().split(' ')))

def find_median(numbers):
	c = Counter(numbers)
	(median, freq) = c.most_common()[0]
	pos = numbers.index(median)
	print(len(numbers) - freq)
	for i in range(pos - 1, -1, -1):
		if numbers[i] > median:
			print('2', i + 1, i + 2)
		elif numbers[i] < median:
			print('1', i + 1, i + 2)
	for i in range(pos + 1, len(numbers)):
		if numbers[i] < median:
			print('1', i + 1, i)
		elif numbers[i] > median:
			print('2', i + 1, i)
find_median(numbers)


import sys
from sys import stdin
import math

def iinput():
	return int(input())

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

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

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

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

def flinput():
	return list(map(int, stdin.readline().strip().split()))
n = iinput()
list1 = linput()
dict1 = {}
for i in range(n):
	if list1[i] in dict1:
		dict1[list1[i]] += 1
	else:
		dict1[list1[i]] = 1
m = 0
ele = 0
for i in dict1:
	if dict1[i] > m:
		m = dict1[i]
		ele = i
ii = 0
for i in range(n):
	if list1[i] == ele:
		ii = i
		break
ll = []
for j in range(ii + 1, n):
	if list1[j] != ele:
		if list1[j] < list1[j - 1]:
			list1[j] = ele
			ll.append([1, j + 1, j])
		else:
			list1[j] = ele
			ll.append([2, j + 1, j])
for j in range(ii - 1, -1, -1):
	if list1[j] != ele:
		if list1[j] < list1[j + 1]:
			list1[j] = ele
			ll.append([1, j + 1, j + 2])
		else:
			list1[j] = ele
			ll.append([2, j + 1, j + 2])
print(len(ll))
for i in range(len(ll)):
	print(*ll[i])


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
ma = max(a)
mi = min(a)
test_list = Counter(a)
ma = test_list.most_common(1)[0][0]
a1 = []
a2 = []
flag = 1
for i in range(n):
	if a[i] != ma and flag == 1:
		if a[i] < ma:
			a1.append([1, i])
		else:
			a1.append([2, i])
	elif a[i] == ma:
		flag = 0
	elif a[i] < ma:
		a2.append([1, i])
	else:
		a2.append([2, i])
a1.reverse()
print(len(a1) + len(a2))
for i in range(len(a1)):
	print(a1[i][0], a1[i][1] + 1, a1[i][1] + 2)
for i in range(len(a2)):
	print(a2[i][0], a2[i][1] + 1, a2[i][1])


n = int(input())
l = list(map(int, input().split()))
times = [0] * 200001
for i in l:
	times[i] += 1
maks = 0
k = 0
for i in range(200001):
	if times[i] > maks:
		k = i
		maks = times[i]
start = 0
for i in range(200001):
	if l[i] == k:
		start = i
		break
wyn = n - maks
print(wyn)
for i in range(start + 1, n):
	if l[i - 1] != l[i]:
		print((l[i] > l[i - 1]) + 1, end=' ')
		print(i + 1, end=' ')
		print(i)
		l[i] = l[i - 1]
i = start
while i > 0:
	if l[i - 1] != l[i]:
		print((l[i - 1] > l[i]) + 1, end=' ')
		print(i, end=' ')
		print(i + 1)
		l[i - 1] = l[i]
	i -= 1


n = int(input())
a = list(map(int, input().split()))
h = [0] * 200001
max_a = 0
max_h = 0
ind = 0
for i in range(len(a)):
	h[a[i]] += 1
	if h[a[i]] > max_h:
		max_h = h[a[i]]
		max_a = a[i]
		ind = i
print(n - max_h)
l = ind - 1
r = ind + 1
while l >= 0 or r <= n - 1:
	if l > -1:
		if a[l] > a[l + 1]:
			a[l] = a[l + 1]
			print(2, l + 1, l + 2)
		elif a[l] < a[l + 1]:
			a[l] = a[l + 1]
			print(1, l + 1, l + 2)
	l -= 1
	if r < n:
		if a[r] > a[r - 1]:
			a[r] = a[r - 1]
			print(2, r + 1, r)
		elif a[r] < a[r - 1]:
			a[r] = a[r - 1]
			print(1, r + 1, r)
	r += 1


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
(m, x) = Counter(l).most_common(1)[0]
print(n - x)
ind = l.index(m)
for i in range(ind, -1, -1):
	if l[i] != m:
		print(1 if l[i] < m else 2, i + 1, i + 2)
for i in range(ind, n):
	if l[i] != m:
		print(1 if l[i] < m else 2, i + 1, i)


from sys import stdin
from collections import Counter
a = int(stdin.readline())
b = list(map(int, stdin.readline().split()))
z = Counter(b).most_common()[0]
print(a - z[1])
z = z[0]
f = b.index(z)
f1 = f
while f >= 0:
	if b[f] != z:
		if b[f] > z:
			print(2, f + 1, f + 2)
		else:
			print(1, f + 1, f + 2)
	f -= 1
while f1 < a:
	if b[f1] != z:
		if b[f1] > z:
			print(2, f1 + 1, f1)
		else:
			print(1, f1 + 1, f1)
	f1 += 1


import sys
from bisect import bisect_left, bisect_right
from collections import deque
inf = float('inf')
mod = 1000000007

def binary(number):
	result = 0
	while number:
		result = result + 1
		number = number & number - 1
	return result

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

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

def main():
	n = int(input())
	array = get_array()
	max_val = 0
	max_cnt = 0
	last_val = -inf
	cnt = 0
	stack = []
	sorted_array = sorted(array)
	for i in range(len(sorted_array)):
		if last_val == -inf:
			last_val = sorted_array[i]
			cnt = 1
			continue
		if last_val == sorted_array[i]:
			cnt += 1
		else:
			if cnt > max_cnt:
				max_cnt = cnt
				max_val = last_val
			cnt = 1
			last_val = sorted_array[i]
	if cnt > max_cnt:
		max_cnt = cnt
		max_val = last_val
	has_met = False
	ret = []
	for i in range(len(array)):
		if array[i] == max_val:
			if has_met:
				continue
			else:
				has_met = True
				last_idx = i
				while stack:
					idx = stack.pop()
					if array[idx] > max_val:
						ret.append((2, idx, last_idx))
					elif array[idx] < max_val:
						ret.append((1, idx, last_idx))
					last_idx = idx
		if not has_met:
			stack.append(i)
		elif array[i] > max_val:
			ret.append((2, i, i - 1))
		elif array[i] < max_val:
			ret.append((1, i, i - 1))
	if not ret:
		print(0)
		return
	else:
		print(len(ret))
		for each in ret:
			print('%d %d %d ' % (each[0], each[1] + 1, each[2] + 1))
main()


from collections import Counter
N = int(input())
array = [int(value) for value in input().split()]
counter = Counter(array)
most_common = counter.most_common(1)[0][0]
print(N - counter[most_common])
start_index = 0
while array[start_index] != most_common:
	start_index += 1
for index in range(start_index - 1, -1, -1):
	if array[index] < most_common:
		print(f'1 {index + 1} {index + 2}')
	else:
		print(f'2 {index + 1} {index + 2}')
for index in range(start_index + 1, N):
	if array[index] == most_common:
		continue
	if array[index] > most_common:
		print(f'2 {index + 1} {index}')
	else:
		print(f'1 {index + 1} {index}')


n = int(input())
a = [-1 for i in range(n)]
a[0:n] = map(int, input().split())
c = [0 for i in range(200001)]
maxc = 0
for number in a:
	c[number] += 1
	maxc = max(maxc, c[number])
target = c.index(maxc)
print(n - maxc)
position = a.index(target)
i = position - 1
while i >= 0:
	if a[i] > target:
		print(2, i + 1, i + 2)
	elif a[i] < target:
		print(1, i + 1, i + 2)
	i -= 1
j = position + 1
while j < n:
	if a[j] > target:
		print(2, j + 1, j)
	elif a[j] < target:
		print(1, j + 1, j)
	j += 1


from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import *
from itertools import *
import functools
import sys
import math
import random
MAX = sys.maxsize
MAXN = 10 ** 5 + 10
MOD = 10 ** 9 + 7

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b, x, y):
	return abs(a - x) + abs(b - y)

def numIN(x=' '):
	return map(int, sys.stdin.readline().strip().split(x))

def charIN():
	return sys.stdin.readline().strip().split()

def dis(x, y):
	a = y[0] - x[0]
	b = x[1] - y[1]
	return (a * a + b * b) ** 0.5
n = int(input())
l = list(numIN())
d = defaultdict(int)
mx = -1
x = -1
for i in l:
	d[i] += 1
	if d[i] > mx:
		mx = d[i]
		x = i
i = l.index(x)
ans = []
for j in range(i, 0, -1):
	if l[j] > l[j - 1]:
		l[j - 1] += abs(l[j] - l[j - 1])
		ans.append([1, j, j + 1])
	elif l[j] < l[j - 1]:
		l[j - 1] -= abs(l[j] - l[j - 1])
		ans.append([2, j, j + 1])
	else:
		coninue
for j in range(i, n - 1):
	if l[j + 1] > l[j]:
		l[j + 1] -= abs(l[j] - l[j + 1])
		ans.append([2, j + 2, j + 1])
	elif l[j + 1] < l[j]:
		l[j + 1] += abs(l[j] - l[j + 1])
		ans.append([1, j + 2, j + 1])
	else:
		continue
print(len(ans))
for i in ans:
	print(*i)


from collections import Counter
(n, a) = (int(input()), list(map(int, input().split())))
(v, f) = Counter(a).most_common(1)[0]
print(n - f)
i = a.index(v)
for j in range(i + 1, n):
	if a[j] != v:
		print(1 if a[j] < v else 2, j + 1, j)
for j in range(i - 1, -1, -1):
	if a[j] != v:
		print(1 if a[j] < v else 2, j + 1, j + 2)


n = int(input())
d = dict()
a = list(map(int, input().split()))
mx = 0
for i in a:
	d[i] = 0
for i in range(n):
	d[a[i]] += 1
	if d[a[i]] > d[a[mx]]:
		mx = i
ans = []
for i in range(mx + 1, n):
	op = 0
	if a[i] == a[i - 1]:
		continue
	if a[i] > a[i - 1]:
		op = 2
	else:
		op = 1
	ans.append([op, i + 1, i])
	a[i] = a[i - 1]
for i in range(mx - 1, -1, -1):
	op = 0
	if a[i] == a[i + 1]:
		continue
	if a[i] > a[i + 1]:
		op = 2
	else:
		op = 1
	ans.append([op, i + 1, i + 2])
	a[i] = a[i + 1]
print(len(ans))
for i in ans:
	print(*i)


from collections import Counter
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
R = C.most_common()[0][0]
op = []
l = A.index(R)
r = l
l -= 1
r += 1
while l >= 0:
	if A[l] == R:
		l -= 1
		continue
	elif A[l] < R:
		op.append([1, l + 1, l + 2])
	else:
		op.append([2, l + 1, l + 2])
	l -= 1
while r < N:
	if A[r] == R:
		r += 1
		continue
	elif A[r] < R:
		op.append([1, r + 1, r])
	else:
		op.append([2, r + 1, r])
	r += 1
if len(op):
	print(len(op))
	for l in op:
		print(*l)
else:
	print(len(op))


n = int(input())
l = list(map(int, input().split()))
l1 = [0] * 200005
for i in range(n):
	l1[l[i]] += 1
mx = l1.index(max(l1))
print(n - max(l1))
for i in range(n):
	if l[i] == mx:
		mxi = i
		break
for i in range(mxi - 1, -1, -1):
	if l[i] > l[i + 1]:
		print(2, i + 1, i + 2)
	elif l[i] < l[i + 1]:
		print(1, i + 1, i + 2)
	l[i] = l[i + 1]
for i in range(mxi + 1, n):
	if l[i] > l[i - 1]:
		print(2, i + 1, i)
	elif l[i] < l[i - 1]:
		print(1, i + 1, i)
	l[i] = l[i - 1]


n = int(input())
a = [int(x) for x in input().split()]
m = {}
for i in a:
	m[i] = 0
for i in a:
	m[i] += 1
mx = 0
mxn = 0
for i in m:
	if m[i] > mx:
		mx = m[i]
		mxn = i
print(n - mx)
cnt = 1
ans = []
for i in range(n):
	if a[i] != mxn:
		if a[i] > mxn:
			ans.append([2, i + 1])
		else:
			ans.append([1, i + 1])
		a[i] = mxn
	else:
		break
ans.reverse()
for i in ans:
	print(i[0], i[1], i[1] + 1)
for i in range(n):
	if a[i] > mxn:
		print(2, i + 1, i)
	elif a[i] < mxn:
		print(1, i + 1, i)


import collections

def solve():
	N = int(input())
	A = list(map(int, input().split()))
	c = collections.Counter(A)
	max_count = sorted(c.values(), reverse=True)[0]
	max_key = [k for k in c.keys() if c[k] == max_count][0]
	pivot = A.index(max_key)
	ans = []
	for i in range(pivot - 1, -1, -1):
		if A[i] < max_key:
			ans.append([1, i + 1, i + 2])
		else:
			ans.append([2, i + 1, i + 2])
	for i in range(pivot + 1, N):
		if A[i] == max_key:
			continue
		if A[i] < max_key:
			ans.append([1, i + 1, i])
		else:
			ans.append([2, i + 1, i])
	print(len(ans))
	for a in ans:
		print(' '.join(list(map(str, a))))
solve()


from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
if len(set(arr)) == 1:
	print(0)
else:
	C = Counter(arr)
	mx = 0
	key = arr[0]
	ops = []
	for keys in C:
		if C[keys] > mx:
			mx = C[keys]
			key = keys
	idxArr = []
	for i in range(n):
		if arr[i] == key:
			idxArr.append(i)
	for i in range(len(idxArr)):
		if i == 0:
			for j in range(idxArr[i] - 1, -1, -1):
				if arr[j] < key:
					ops.append([1, j + 1, j + 2])
				else:
					ops.append([2, j + 1, j + 2])
			for j in range(idxArr[i] + 1, n, 1):
				if arr[j] == key:
					break
				if arr[j] < key:
					ops.append([1, j + 1, j])
				else:
					ops.append([2, j + 1, j])
		else:
			for j in range(idxArr[i] + 1, n, 1):
				if arr[j] == key:
					break
				if arr[j] < key:
					ops.append([1, j + 1, j])
				else:
					ops.append([2, j + 1, j])
	print(len(ops))
	for i in ops:
		print(*i)


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
from collections import Counter

def get_targets(n, a):
	best_count = -1
	best_target = None
	count = Counter(a)
	for (target, c) in count.items():
		if c > best_count:
			best_count = c
			best_target = target
	indexes = []
	for i in range(n):
		if a[i] == best_target:
			indexes.append(i)
	return (best_target, indexes)
(target, indexes) = get_targets(n, a)
res = []
MAX = n - 1
for index in indexes:
	i = index
	while i > 0:
		if a[i - 1] == target:
			break
		sign = 1 if target > a[i - 1] else 2
		a[i - 1] = target
		res.append((sign, i, i + 1))
		i -= 1
	i = index
	while i < MAX:
		if a[i + 1] == target:
			break
		sign = 1 if target > a[i + 1] else 2
		a[i + 1] = target
		res.append((sign, i + 2, i + 1))
		i += 1
print(len(res))
for t in res:
	print(*t)


from collections import Counter
N = int(input())
List = [int(x) for x in input().split()]
Dict = Counter(List)
(Val, Count) = Dict.most_common(1)[0]
print(N - Count)
Index = List.index(Val)
for i in range(Index, N):
	if List[i] > Val:
		print(2, i + 1, i)
	elif List[i] < Val:
		print(1, i + 1, i)
for i in range(Index, -1, -1):
	if List[i] > Val:
		print(2, i + 1, i + 2)
	elif List[i] < Val:
		print(1, i + 1, i + 2)


def most_frequent(arr):
	memo = {}
	most = 0
	element = None
	for a in arr:
		if a not in memo:
			memo[a] = 0
		memo[a] += 1
	for (k, v) in memo.items():
		if v > most:
			element = k
			most = v
	idx = arr.index(element)
	return idx

def solution(arr, idx):
	cnt = 0
	oprs = []
	left = idx - 1
	right = idx + 1
	while left >= 0:
		if arr[left] > arr[idx]:
			cnt += 1
			oprs.append([2, left + 1, left + 2])
		elif arr[left] < arr[idx]:
			cnt += 1
			oprs.append([1, left + 1, left + 2])
		left -= 1
	while right < len(arr):
		if arr[idx] > arr[right]:
			cnt += 1
			oprs.append([1, right + 1, right])
		elif arr[idx] < arr[right]:
			cnt += 1
			oprs.append([2, right + 1, right])
		right += 1
	return [cnt, oprs]
n = int(input())
arr = [int(i) for i in input().split()]
idx = most_frequent(arr)
(cnt, oprs) = solution(arr, idx)
if not cnt:
	print(0)
else:
	print(cnt)
	for o in oprs:
		print(*o)


from collections import Counter

def equal_all(seq):
	if len(seq) <= 1:
		print(0)
		return
	counts = Counter(seq)
	(element, count) = counts.most_common(1)[0]
	if count == 1:
		position = len(seq) // 2
		element = seq[position]
	else:
		position = [i for (i, val) in enumerate(seq) if val == element][0]
	operations = []
	for i in range(position - 1, -1, -1):
		if seq[i] == element:
			continue
		if seq[i] < element:
			op_type = 1
		else:
			op_type = 2
		operations.append((op_type, i + 1, i + 2))
	for i in range(position + 1, len(seq)):
		if seq[i] == element:
			continue
		if seq[i] < element:
			op_type = 1
		else:
			op_type = 2
		operations.append((op_type, i + 1, i))
	print(len(operations))
	for op in operations:
		print(' '.join(map(str, op)))
n = input()
seq = [int(el) for el in input().split()]
equal_all(seq)


def calc(n, a):
	dic = {}
	for i in a:
		if i not in dic:
			dic[i] = 1
		else:
			dic[i] += 1
	val = 0
	big = 0
	for i in dic:
		if dic[i] > val:
			val = dic[i]
			big = i
	if val == n:
		print(0)
		return
	if val == 1:
		print(n - 1)
		for i in range(1, n):
			if a[i] > a[i - 1]:
				print(2, i + 1, i)
				a[i] = a[i - 1]
			else:
				print(1, i + 1, i)
			a[i] = a[i - 1]
	else:
		print(n - val)
		index = a.index(big)
		i = index + 1
		while i < n:
			if a[i] < a[i - 1]:
				print(1, i + 1, i)
				a[i] = a[i - 1]
			elif a[i] > a[i - 1]:
				print(2, i + 1, i)
				a[i] = a[i - 1]
			i = i + 1
		j = index - 1
		while j >= 0:
			if a[j] > a[j + 1]:
				print(2, j + 1, j + 2)
				a[j] = a[j + 1]
			elif a[j] < a[j + 1]:
				print(1, j + 1, j + 2)
				a[j] = a[j + 1]
			j -= 1
n = int(input())
a = list(map(int, input().split()))
calc(n, a)


n = int(input())
l = [int(x) for x in input().split()]
f = [0 for i in range(200001)]
for i in l:
	f[i] += 1
z = max(f)
num = f.index(z)
index = l.index(num)
print(n - f[num])
for i in range(index - 1, -1, -1):
	if l[i] != num:
		if l[i] > num:
			print(2, i + 1, i + 2)
		else:
			print(1, i + 1, i + 2)
for i in range(index + 1, n):
	if l[i] != num:
		if l[i] > num:
			print(2, i + 1, i)
		else:
			print(1, i + 1, i)


n = int(input())
a = [int(s) for s in input().split()]
cts = {}
maxct = 1
maxn = a[0]
for ai in a:
	cts[ai] = cts.get(ai, 0) + 1
	if cts[ai] > maxct:
		maxct = cts[ai]
		maxn = ai
print(n - maxct)

def sweep(st, en, step):
	for i in range(st, en, step):
		if a[i + step] < a[i]:
			print(1, i + step + 1, i + 1)
		elif a[i + step] > a[i]:
			print(2, i + step + 1, i + 1)
		a[i + step] = a[i]
sti = a.index(maxn)
sweep(sti, 0, -1)
sweep(sti, n - 1, 1)


import collections
n = int(input())
a = input().split(' ')
count = collections.Counter()
at = []
for el in a:
	count[el] += 1
	at.append(int(el))
a = at
k = max(count, key=count.get)
tk = int(k)
print(n - count[k])
pos = 0
con = 0
tcon = 0
arcon = 0
while pos < n:
	if a[pos] == tk:
		arcon += 1
		while con > tcon:
			if a[con - 1] > a[con]:
				print(2, con - 1 + 1, con + 1)
			else:
				print(1, con - 1 + 1, con + 1)
			con -= 1
			a[con] = a[pos]
		tcon = pos + 1
		con = pos
		if arcon == count[k]:
			while pos < n - 1:
				if a[pos + 1] > a[pos]:
					print(2, pos + 2, pos + 1)
				else:
					print(1, pos + 2, pos + 1)
				a[pos + 1] = a[pos]
				pos += 1
	con += 1
	pos += 1


N = int(input())
L = list(map(int, input().split()))
curm = 0
maps = {}
curv = 0
for l in L:
	if l not in maps:
		maps[l] = 1
	else:
		maps[l] += 1
	curm = max(curm, maps[l])
	if curm == maps[l]:
		curv = l
i = L.index(curv)
print(N - curm)
for k in range(i + 1, len(L)):
	if L[k] > curv:
		print(2, end=' ')
		print(k + 1, end=' ')
		print(k)
	if L[k] < curv:
		print(1, end=' ')
		print(k + 1, end=' ')
		print(k)
for k in range(i - 1, -1, -1):
	if L[k] > curv:
		print(2, end=' ')
		print(k + 1, end=' ')
		print(k + 2)
	if L[k] < curv:
		print(1, end=' ')
		print(k + 1, end=' ')
		print(k + 2)


(n, l) = (int(input()), list(map(int, input().split())))
d = {}
(mx, index) = (0, 0)
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
	if d[i] > mx:
		mx = d[i]
		index = i
print(n - mx)
i = l.index(index)
j = i
while j >= 0:
	if l[j] > index:
		print(2, j + 1, j + 2)
	elif l[j] < index:
		print(1, j + 1, j + 2)
	j -= 1
while i < n:
	if l[i] > index:
		print(2, i + 1, i)
	elif l[i] < index:
		print(1, i + 1, i)
	i += 1


from collections import Counter
n = int(input())
lt = [int(x) for x in input().split()]
maxi = Counter(lt).most_common(1)[0][0]
ind = lt.index(maxi)
ans = []
(t, i, j) = (0, 0, 0)
for m in range(ind - 1, -1, -1):
	if lt[m] > lt[ind]:
		(t, i, j) = (2, m + 1, m + 2)
		ans.append([t, i, j])
	elif lt[m] < lt[ind]:
		(t, i, j) = (1, m + 1, m + 2)
		ans.append([t, i, j])
for m in range(ind + 1, n):
	if lt[m] < lt[ind]:
		(t, i, j) = (1, m + 1, m)
		ans.append([t, i, j])
	elif lt[m] > lt[ind]:
		(t, i, j) = (2, m + 1, m)
		ans.append([t, i, j])
print(len(ans))
for c in ans:
	print(*c)


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


from math import factorial, ceil, pow, sqrt, floor
from sys import stdin, stdout
from collections import defaultdict, Counter, deque
n = int(stdin.readline())
l = list(map(int, stdin.readline().split()))
s = [0] * 10 ** 6
for i in l:
	s[i] += 1
m = 0
z = 0
for i in range(len(s)):
	if s[i] > m:
		m = s[i]
		z = i
q = 0
print(len(l) - m)
for i in range(len(l)):
	if l[i] == z:
		for j in range(i - 1, q - 1, -1):
			if l[j] > z:
				print(2, j + 1, j + 2)
			else:
				print(1, j + 1, j + 2)
		q = i + 1
for j in range(q, len(l)):
	if l[j] > z:
		print(2, j + 1, j)
	else:
		print(1, j + 1, j)


n = int(input())
a = [int(item) for item in input().split()]
m = {key: 0 for key in a}
for x in a:
	m[x] += 1
mx = -1
e = -1
for i in range(n):
	if m[a[i]] > mx:
		mx = m[a[i]]
		e = a[i]
last = -1
ans = 0
ops = []
for i in range(n):
	if a[i] == e and i > last + 1:
		for k in range(i - 1, last, -1):
			op = [0, k + 1, k + 1 + 1]
			if a[k] > e:
				op[0] = 2
			elif a[k] < e:
				op[0] = 1
			else:
				raise
			ops.append(op)
	if a[i] == e:
		last = i
for k in range(last + 1, n):
	op = [0, k + 1, k - 1 + 1]
	if a[k] > e:
		op[0] = 2
	elif a[k] < e:
		op[0] = 1
	else:
		raise
	ops.append(op)
print(len(ops))
for op in ops:
	print(*op)


n = int(input())
a = list(map(int, input().split()))
pa = [0] * 200050
mx = -1
ele = -1
for i in a:
	pa[i] += 1
for i in range(len(pa)):
	if pa[i] > mx:
		mx = pa[i]
		ele = i
t = len(a) - mx
fi = a.index(ele)
ite = fi - 1
print(t)
while ite >= 0:
	if a[ite] > ele:
		print(2, ite + 1, ite + 2)
	else:
		print(1, ite + 1, ite + 2)
	ite -= 1
ite = fi
while ite < len(a) - 1:
	if a[ite + 1] > ele:
		print(2, ite + 2, ite + 1)
	elif a[ite + 1] < ele:
		print(1, ite + 2, ite + 1)
	ite += 1


n = int(input())
A = list(map(int, input().split()))
S = set(A)
D = {}
for i in A:
	if i in list(D.keys()):
		D[i] += 1
	else:
		D[i] = 1
p = sorted(list(D.items()), key=lambda x: x[1])
max_number = p[-1][0]
first_index = A.index(max_number)
print(len(A) - p[-1][1])
for i in range(first_index - 1, -1, -1):
	if A[i] < max_number:
		x = 1
	else:
		x = 2
	print(x, i + 1, i + 2)
for i in range(first_index + 1, n):
	if A[i] == max_number:
		continue
	if A[i] < max_number:
		x = 1
	else:
		x = 2
	print(x, i + 1, i)


import math
from collections import defaultdict, Counter, deque

def primeFactor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i ** 2 <= n:
		if n % i == 0:
			return i
		i += 1
	return n

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	req_ele = 0
	req = 0
	m = 0
	curr = -1
	arr2 = sorted(arr)
	for i in range(n):
		if curr == -1 or arr2[i] == curr:
			req += 1
			curr = arr2[i]
		else:
			if m < req:
				m = req
				req_ele = curr
			curr = arr2[i]
			req = 1
	if m < req:
		m = req
		req_ele = curr
	max_req = (m, req_ele)
	left = arr.index(max_req[1])
	right = arr.index(max_req[1])
	print(n - max_req[0])
	while left >= 0 or right < n:
		if left < n - 1 and left >= 0 and (arr[left] != max_req[1]):
			if arr[left] < max_req[1]:
				arr[left] = arr[left] + abs(arr[left + 1] - arr[left])
				print(1, left + 1, left + 2)
			else:
				arr[left] = arr[left] - abs(arr[left + 1] - arr[left])
				print(2, left + 1, left + 2)
		if right > 0 and right < n and (arr[right] != max_req[1]):
			if arr[right] < max_req[1]:
				arr[right] = arr[right - 1] + abs(arr[right - 1] - arr[right])
				print(1, right + 1, right)
			else:
				arr[right] = arr[right] - abs(arr[right - 1] - arr[right])
				print(2, right + 1, right)
		left -= 1
		right += 1
t = 1
for _ in range(t):
	main()


from collections import *
n = int(input())
l = list(map(int, input().strip().split()))
arr = []
ans = 0
d = Counter(l)
key = 0
val = 0
for i in d:
	if d[i] > val:
		key = i
		val = d[i]
ind = l.index(key)
for i in range(ind - 1, -1, -1):
	if l[i] > key:
		ans += 1
		l[i] = l[i] - (l[i] - key)
		arr.append([2, i + 1, i + 2])
	elif l[i] < key:
		l[i] = l[i] + (key - l[i])
		arr.append([1, i + 1, i + 2])
		ans += 1
new = []
for i in range(ind + 1, n, 1):
	if l[i] > key:
		l[i] = l[i] - (l[i] - key)
		new.append([2, i + 1, i])
		ans += 1
	elif l[i] < key:
		l[i] = l[i] + (key - l[i])
		new.append([1, i + 1, i])
		ans += 1
print(ans)
for i in range(len(new)):
	print(*new[i][:])
for i in range(len(arr)):
	print(*arr[i][:])


n = int(input())
a = list(map(int, input().split()))
b = [0] * 200001
c = [0] * 200001
for i in range(n):
	b[a[i]] += 1
	c[a[i]] = i
maxi = 0
for i in range(200001):
	if b[i] > maxi:
		maxi = b[i]
		x = i
		y = c[i]
print(n - b[x])
for i in range(y + 1, n):
	if a[i] != x:
		if a[i] > x:
			print(2, i + 1, i)
		else:
			print(1, i + 1, i)
d = y
while d >= 0:
	if a[d] != x:
		if a[d] > x:
			print(2, d + 1, d + 2)
		if a[d] < x:
			print(1, d + 1, d + 2)
	d -= 1


from io import BytesIO, IOBase
from math import sqrt
import sys, os
inpl = lambda : list(map(int, input().split()))
inpm = lambda : map(int, input().split())
inpi = lambda : int(input())
inp = lambda : input()
(rev, ra, l) = (reversed, range, len)
P = print
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))

def input():
	return sys.stdin.readline().rstrip('\r\n')

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

def factors(n):
	arr = []
	for i in ra(2, int(sqrt(n)) + 1):
		if n % i == 0:
			arr.append(i)
			if i * i != n:
				arr.append(int(n / i))
	return arr

def dfs(arr, n):
	pairs = [[i + 1] for i in ra(n)]
	vis = [0] * (n + 1)
	for i in ra(l(arr)):
		pairs[arr[i][0] - 1].append(arr[i][1])
	pairs[arr[i][1] - 1].append(arr[i][0])
	comp = []
	for i in ra(n):
		stack = [pairs[i]]
		temp = []
		if vis[stack[-1][0]] == 0:
			while len(stack) > 0:
				if vis[stack[-1][0]] == 0:
					temp.append(stack[-1][0])
					vis[stack[-1][0]] = 1
					s = stack.pop()
					for j in s[1:]:
						if vis[j] == 0:
							stack.append(pairs[j - 1])
				else:
					stack.pop()
			comp.append(temp)
	return comp
from bisect import bisect_left as bl
from bisect import bisect_right as br
import sys, operator, math, operator
import random
from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
d = Counter(arr)
d = d.most_common()
e = d[0][0]
minn = arr.index(e)
print(n - d[0][1])
ans = []
flag = False
for i in range(minn, n):
	if i + 1 < n and arr[i + 1] > e:
		ans.append([2, i + 2, i + 1])
	if i + 1 < n and arr[i + 1] < e:
		ans.append([1, i + 2, i + 1])
for j in range(minn, -1, -1):
	if j - 1 >= 0 and arr[j - 1] > e:
		ans.append([2, j, j + 1])
	elif j - 1 >= 0 and arr[j - 1] < e:
		ans.append([1, j, j + 1])
for i in ans:
	print(*i)


n = int(input())
A = list(map(int, input().split()))
from collections import Counter
C = Counter(A)
C = list(C.items())
C.sort(reverse=True, key=lambda x: x[1])
x = C[0][0]
for (i, a) in enumerate(A):
	if a == x:
		break
ans = []
for j in reversed(range(i)):
	if A[j] > x:
		ans.append((2, j + 1, j + 2))
	else:
		ans.append((1, j + 1, j + 2))
for j in range(i + 1, n):
	if A[j] > x:
		ans.append((2, j + 1, j))
	elif A[j] < x:
		ans.append((1, j + 1, j))
	else:
		continue
print(len(ans))
for i in ans:
	print(*i)


def main():
	n = int(input())
	array = list(map(int, input().split()))
	counts = {}
	for i in array:
		if i not in counts.keys():
			counts[i] = 1
		else:
			counts[i] += 1
	max_count = 0
	num = 0
	for i in counts:
		if counts[i] > max_count:
			max_count = counts[i]
			num = i
	ans = []
	orders = []
	order = []
	for i in range(n):
		if array[i] != num:
			order.append(i)
		else:
			order.reverse()
			orders.append(order)
			order = []
	if order:
		orders.append(order)
	ans = []
	for order in orders:
		for i in order:
			if i > 0:
				if array[i - 1] == num:
					if array[i] > num:
						ans.append([2, i + 1, i])
					else:
						ans.append([1, i + 1, i])
					array[i] = num
				if i < n - 1:
					if array[i + 1] == num and array[i] != num:
						if array[i] > num:
							ans.append([2, i + 1, i + 2])
						else:
							ans.append([1, i + 1, i + 2])
						array[i] = num
			elif array[i + 1] == num:
				if array[i] > num:
					ans.append([2, i + 1, i + 2])
				else:
					ans.append([1, i + 1, i + 2])
				array[i] = num
	print(len(ans))
	for i in ans:
		for j in i:
			print(j, end=' ')
		print()
main()


from collections import Counter

def __starting_point():
	n = int(input())
	array = list(map(int, input().split()))
	frequencies = Counter(array)
	(target_value, max_frequency) = frequencies.most_common(1)[0]
	print(n - max_frequency)
	value_found = False
	for i in range(n):
		elem = array[i]
		if value_found and elem != target_value:
			if elem > target_value:
				print(2, i + 1, i)
			else:
				print(1, i + 1, i)
			array[i] = target_value
		elif elem == target_value:
			value_found = True
	value_found = False
	for i in range(n - 1, -1, -1):
		elem = array[i]
		if value_found and elem != target_value:
			if elem > target_value:
				print(2, i + 1, i + 2)
			else:
				print(1, i + 1, i + 2)
			array[i] = target_value
		elif elem == target_value:
			value_found = True
__starting_point()


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
mf = Counter(a).most_common()[0][0]
op = []
st = a.index(mf)
for i in range(st + 1, n):
	if a[i] > mf:
		op.append([2, i + 1, i])
	elif a[i] < mf:
		op.append([1, i + 1, i])
for i in range(st - 1, -1, -1):
	if a[i] > mf:
		op.append([2, i + 1, i + 2])
	elif a[i] < mf:
		op.append([1, i + 1, i + 2])
if len(op) == 0:
	print(0)
else:
	print(len(op))
	for i in op:
		print(*i)


n = int(input())
a = list(map(int, input().split()))
o = []
podsch = [0 for i in range(2 * 10 ** 5 + 1)]
ist = [[] for i in range(2 * 10 ** 5 + 1)]
for i in range(n):
	podsch[a[i]] += 1
	ist[a[i]].append(i)
maxi = 0
for i in range(len(podsch)):
	if podsch[maxi] < podsch[i]:
		maxi = i
beg = min(ist[maxi])
for i in range(beg, 0, -1):
	if a[i - 1] > a[i]:
		o.append([2, i, i + 1])
		a[i - 1] = a[i]
	elif a[i - 1] != a[i]:
		o.append([1, i, i + 1])
		a[i - 1] = a[i]
for i in range(beg, n - 1):
	if a[i + 1] > a[i]:
		o.append([2, i + 2, i + 1])
		a[i + 1] = a[i]
	elif a[i + 1] != a[i]:
		o.append([1, i + 2, i + 1])
		a[i + 1] = a[i]
print(len(o))
for i in o:
	print(*i)


from collections import Counter
n = int(input())
s = input().split()
A = [int(i) for i in s]
cnt = Counter(A)
(res, max_cnt) = (0, 0)
for i in cnt:
	if cnt[i] > max_cnt:
		max_cnt = cnt[i]
		res = i
min_op = len(A) - max_cnt
print(min_op)
index = 0
for (i, num) in enumerate(A):
	if num == res:
		index = i
		break
for i in range(index, -1, -1):
	if A[i] < res:
		print(1, i + 1, i + 2)
	if A[i] > res:
		print(2, i + 1, i + 2)
for i in range(index + 1, len(A)):
	if A[i] < res:
		print(1, i + 1, i)
	if A[i] > res:
		print(2, i + 1, i)


n = int(input())
arr = list(map(int, input().split()))
counter = {}
for a in arr:
	counter[a] = counter.get(a, 0) + 1
need = sorted(counter.items(), key=lambda d: d[1], reverse=True)[0][0]
pre = -1
operations = []
i = 0
while i < n:
	if arr[i] == need:
		i += 1
		continue
	elif i > 0:
		if arr[i] > need:
			operations.append((2, i + 1, i))
		else:
			operations.append((1, i + 1, i))
		i += 1
	else:
		j = i + 1
		while arr[j] != need:
			j += 1
		i = j + 1
		while j > 0:
			if arr[j - 1] > need:
				operations.append((2, j, j + 1))
			else:
				operations.append((1, j, j + 1))
			j -= 1
print(len(operations))
for i in range(len(operations)):
	print('%d %d %d' % operations[i])


import sys
input = sys.stdin.readline
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
cnt = Counter(a)
M = 0
mark = -1
for (k, v) in cnt.items():
	if v > M:
		M = v
		mark = k
print(n - M)
sta = 0
mark_cnt = 0
for i in range(n):
	if a[i] == mark:
		for j in range(i - 1, sta - 1, -1):
			if a[j] < mark:
				print(1, j + 1, j + 2)
			else:
				print(2, j + 1, j + 2)
		sta = i + 1
		mark_cnt += 1
		if mark_cnt == M:
			for j in range(i, n - 1):
				if mark > a[j + 1]:
					print(1, j + 2, j + 1)
				else:
					print(2, j + 2, j + 1)
			break


n = int(input())
In = input().split()
arr = []
dicr = {}
for i in range(n):
	arr.append(int(In[i]))
	if dicr.get(int(In[i])):
		dicr[int(In[i])] += 1
	else:
		dicr[int(In[i])] = 1
maxValue = max(dicr.keys(), key=lambda k: dicr[k])
print(n - dicr[maxValue])
for i in range(arr.index(maxValue), 0, -1):
	if maxValue != arr[i - 1]:
		if maxValue > arr[i - 1]:
			print(1, i, i + 1)
		else:
			print(2, i, i + 1)
for i in range(arr.index(maxValue) - 1, n - 1):
	if maxValue != arr[i + 1]:
		if maxValue > arr[i + 1]:
			print(1, i + 2, i + 1)
		else:
			print(2, i + 2, i + 1)


from collections import defaultdict as dd

def main():
	n = int(input())
	a = list(map(int, input().split()))
	cnt = dd(int)
	for val in a:
		cnt[val] += 1
	targetVal = -1
	targetValCnt = -1
	for (k, v) in cnt.items():
		if v > targetValCnt:
			targetValCnt = v
			targetVal = k
	operations = []
	pos = 0
	while a[pos] != targetVal:
		pos += 1
	posLeft = pos - 1
	while posLeft >= 0:
		if a[posLeft] != targetVal:
			operations.append((1 if a[posLeft] < targetVal else 2, posLeft + 1, posLeft + 2))
		posLeft -= 1
	while pos + 1 < len(a):
		if a[pos + 1] != targetVal:
			operations.append((1 if a[pos + 1] < targetVal else 2, pos + 2, pos + 1))
		pos += 1
	print(len(operations))
	for op in operations:
		print(' '.join(map(str, op)))
main()


from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def solve():
	mxN = int(200000.0 + 5)
	freq = [0] * mxN
	n = ii()
	a = li()
	for i in a:
		freq[i] += 1
	x = freq.index(max(freq))
	pos = a.index(x)
	ans = []
	for j in range(pos - 1, -1, -1):
		if a[j] > a[j + 1]:
			ans.append([2, j + 1, j + 2])
			a[j] = x
		else:
			ans.append([1, j + 1, j + 2])
			a[j] = x
	for i in range(pos + 1, n):
		if a[i] != x:
			if a[i] > a[i - 1]:
				ans.append([2, i + 1, i])
			else:
				ans.append([1, i + 1, i])
			a[i] = x
	print(len(ans))
	for i in ans:
		print(*i)
solve()


import collections

def SI():
	return input()

def II():
	return int(SI())

def STI():
	return SI().split()

def ITI():
	return map(int, STI())

def SLI():
	return list(SI())

def ILI():
	return list(ITI())
n = II()
a = ILI()
ac = collections.Counter(a)
frequent_number = -1
frequency = 0
for (k, v) in sorted(ac.items(), key=lambda x: -x[1]):
	frequent_number = k
	frequency = v
	break
frequent_number_index = a.index(frequent_number)
print(n - frequency)
for i in range(frequent_number_index - 1, -1, -1):
	if a[i] < frequent_number:
		print(1, i + 1, i + 2)
	elif a[i] > frequent_number:
		print(2, i + 1, i + 2)
for i in range(frequent_number_index + 1, n):
	if a[i] < frequent_number:
		print(1, i + 1, i)
	elif a[i] > frequent_number:
		print(2, i + 1, i)


import collections
n = int(input())
x = list(map(int, input().split()))
mc = collections.Counter(x).most_common(1)[0][0]
index_mc = x.index(mc)
print(n - x.count(mc))
for i in range(index_mc, 0, -1):
	if x[i - 1] > mc:
		print(2, i, i + 1)
	elif x[i - 1] < mc:
		print(1, i, i + 1)
for j in range(index_mc, n - 1):
	if x[j + 1] > mc:
		print(2, j + 2, j + 1)
	elif x[j + 1] < mc:
		print(1, j + 2, j + 1)


N = int(input())
A = [int(a) for a in input().split()]
B = [0] * (2 * 10 ** 5 + 10)
for a in A:
	B[a] += 1
ma = 0
mai = 0
for i in range(len(B)):
	if B[i] > ma:
		ma = B[i]
		maa = i
for i in range(N):
	if A[i] == maa:
		mai = i
		break
print(N - ma)
for i in range(mai)[::-1]:
	if A[i] < maa:
		print(1, i + 1, i + 2)
	elif A[i] > maa:
		print(2, i + 1, i + 2)
for i in range(mai + 1, N):
	if A[i] < maa:
		print(1, i + 1, i)
	elif A[i] > maa:
		print(2, i + 1, i)


import math

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

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

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

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

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

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
(n, a) = na()
d = {}
for i in a:
	d[i] = d.get(i, 0) + 1
ls = list(d.keys())
mx = ls[0]
k = d[mx]
for i in ls:
	if d[i] > k:
		k = d[i]
		mx = i
ind = 0
for i in range(n):
	if a[i] == mx:
		ind = i
		break
izm = ind + 1
ans = []
for i in range(ind - 1, -1, -1):
	if a[i] < mx:
		ans.append((1, izm - 1, izm))
		izm = izm - 1
		a[izm - 1] = mx
	elif a[i] != mx:
		ans.append((2, izm - 1, izm))
		izm = izm - 1
		a[izm - 1] = mx
	else:
		izm = izm - 1
if len(set(a)) == 0:
	ahahah = 1
else:
	izm = ind + 1
	for i in range(n):
		if a[i] < mx:
			ans.append((1, izm + 1, izm))
			izm = izm + 1
		elif a[i] != mx:
			ans.append((2, izm + 1, izm))
			izm = izm + 1
		else:
			izm = i + 1
print(len(ans))
for i in ans:
	print(i[0], i[1], i[2])


from sys import stdin, setrecursionlimit, stdout
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

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

def fi():
	return float(stdin.readline())

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

def fmi():
	return map(float, stdin.readline().split())

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

def si():
	return stdin.readline().rstrip()

def lsi():
	return list(si())
res = ['Yes', 'No']
test_case = 1
while test_case:
	test_case -= 1
	n = ii()
	a = li()
	d = dict()
	for i in range(n):
		if a[i] in d:
			d[a[i]].append(i)
		else:
			d[a[i]] = [i]
	mx = val = 0
	for i in d:
		if len(d[i]) > mx:
			mx = len(d[i])
			val = i
	p = min(d[val])
	ans = []
	for i in range(p, 0, -1):
		x = 1
		if val < a[i - 1]:
			x = 2
		ans.append([x, i, i + 1])
	for i in range(p + 1, n):
		if val != a[i]:
			x = 1
			if val < a[i]:
				x = 2
			ans.append([x, i + 1, i])
	print(len(ans))
	for i in ans:
		print(*i)


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
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 main():
	n = int(input())
	a = list(map(int, input().split()))
	d = collections.Counter(a)
	sd = sorted(d.items(), key=lambda x: x[1])
	x = sd[-1][0]
	suffix = []
	pos = n
	for i in range(n, 0, -1):
		if a[i - 1] == x:
			pos = i
			break
	for i in range(pos, n + 1):
		if a[i - 1] > x:
			suffix.append((2, i, i - 1))
		elif a[i - 1] < x:
			suffix.append((1, i, i - 1))
	prefix = []
	for i in range(1, pos):
		if a[i - 1] > x:
			prefix.append((2, i, i + 1))
		elif a[i - 1] < x:
			prefix.append((1, i, i + 1))
	ans = prefix[::-1] + suffix
	if len(ans) == 0:
		print(0)
	else:
		print(len(ans))
		for a in ans:
			print(a[0], a[1], a[2])
main()


from collections import defaultdict as ddict
n = int(input())
a = list(map(int, input().split()))
count = ddict(list)
main_key = 0
max_len = 0
for (i, it) in enumerate(a):
	count[it].append(i)
for k in count:
	if len(count[k]) > max_len:
		max_len = len(count[k])
		main_key = count[k][0]
if max_len == n:
	print(0)
	exit()
ans = list()
for i in range(main_key - 1, -1, -1):
	if a[i] == a[main_key]:
		continue
	if a[i] > a[main_key]:
		ans.append((2, i + 1, i + 2))
	else:
		ans.append((1, i + 1, i + 2))
for i in range(main_key + 1, n):
	if a[i] == a[main_key]:
		continue
	if a[i] > a[main_key]:
		ans.append((2, i + 1, i))
	else:
		ans.append((1, i + 1, i))
print(len(ans))
for it in ans:
	print('%d %d %d' % it)


n = int(input())
A = [int(s) for s in input().split()]
count = {}
max_count = 1
most_common = A[0]

def equalise(start_index, end_index, step):
	for i in range(start_index, end_index, step):
		if A[i + step] < A[i]:
			print(1, i + step + 1, i + 1)
		elif A[i + step] > A[i]:
			print(2, i + step + 1, i + 1)
		A[i + step] = A[i]
for value in A:
	count[value] = count.get(value, 0) + 1
	if count[value] > max_count:
		max_count = count[value]
		most_common = value
print(n - max_count)
start = A.index(most_common)
equalise(start, 0, -1)
equalise(start, n - 1, 1)


n = int(input())
a = list(map(int, input().split()))
d = {}
for c in a:
	d[c] = d.get(c, 0) + 1
km = a[0]
for c in d:
	if d[c] > d[km]:
		km = c
pos = 0
for i in range(n):
	if a[i] == km:
		pos = i
		break
print(n - d[km])
for i in range(pos + 1, n):
	if a[i] > km:
		print(2, i + 1, i)
	elif a[i] < km:
		print(1, i + 1, i)
for i in range(pos - 1, -1, -1):
	if a[i] > km:
		print(2, i + 1, i + 2)
	elif a[i] < km:
		print(1, i + 1, i + 2)


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
P = lambda x: stdout.write(x)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
N = 10 ** 9 + 7
n = I()
a = list(R())
v = [0] * (2 * 10 ** 5 + 7)
for i in a:
	v[i] += 1
mx = m = 0
for i in range(2 * 10 ** 5 + 7):
	if v[i] > mx:
		mx = v[i]
		m = i
s = a.index(m)
ans = []
for i in range(s, 0, -1):
	if a[i - 1] > m:
		ans.append((2, i, i + 1))
	elif a[i - 1] < m:
		ans.append((1, i, i + 1))
for i in range(s + 1, n):
	if a[i] > m:
		ans.append((2, i + 1, i))
	elif a[i] < m:
		ans.append((1, i + 1, i))
print(len(ans))
for i in ans:
	print(*i)


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
m = -1
maxInd = -1
c = Counter(a)
cur = c.most_common(1)[0][0]
curInd = a.index(cur)
prev = curInd + 1
res = []
for i in range(curInd + 1, len(a)):
	if a[i] > cur:
		res.append([2, i + 1, prev])
	elif a[i] < cur:
		res.append([1, i + 1, prev])
	prev += 1
prev = curInd + 1
for i in range(curInd - 1, -1, -1):
	if a[i] > cur:
		res.append([2, i + 1, prev])
	elif a[i] < cur:
		res.append([1, i + 1, prev])
	prev -= 1
print(len(res))
for i in res:
	print(i[0], i[1], i[2])


n = int(input())
a = list(map(int, input().split()))
d = {}
for i in a:
	if d.get(i) is not None:
		d[i] += 1
	else:
		d[i] = 1
max_k = -1
max_v = -1
for k in d:
	if d[k] > max_v:
		max_v = d[k]
		max_k = k
idx = -1
for (id_, i) in enumerate(a):
	if i == max_k:
		idx = id_
		break
ops = []
id_ = idx
while id_ > 0:
	if a[id_] == a[id_ - 1]:
		id_ -= 1
		continue
	ops.append(' '.join(['1' if a[id_] > a[id_ - 1] else '2', str(id_), str(id_ + 1)]))
	a[id_ - 1] = a[id_]
	id_ -= 1
id_ = idx
while id_ < n - 1:
	if a[id_] == a[id_ + 1]:
		id_ += 1
		continue
	ops.append(' '.join(['1' if a[id_] > a[id_ + 1] else '2', str(id_ + 2), str(id_ + 1)]))
	a[id_ + 1] = a[id_]
	id_ += 1
print(len(ops))
for i in ops:
	print(i)


n = int(input(''))
a = list(map(int, input().split()))
b = []
c = []
for i in range(200005):
	c.append(0)
mc = -1
m = -1
for i in range(len(a)):
	c[a[i]] += 1
	if c[a[i]] >= mc:
		mc = c[a[i]]
		m = a[i]
ans = 1
u = 0
l = n - 1
if mc == n:
	ans = 0
	print(ans)
for i in range(n):
	if a[i] == m:
		u = i
		break
ud = u
ld = n - u - 1
if ans == 1:
	for i in range(u + 1, n):
		if a[i] == a[i - 1]:
			continue
		elif a[i] > a[i - 1]:
			b.append([2, i + 1, i])
			a[i] = a[i - 1]
		else:
			b.append([1, i + 1, i])
			a[i] = a[i - 1]
	for i in range(u - 1, -1, -1):
		if a[i] == a[i + 1]:
			continue
		elif a[i] > a[i + 1]:
			b.append([2, i + 1, i + 2])
			a[i] = a[i + 1]
		else:
			b.append([1, i + 1, i + 2])
			a[i] = a[i + 1]
	print(len(b))
	for i in range(len(b)):
		for j in range(3):
			print(b[i][j], end=' ')
		print()


n = int(input())
ai = list(map(int, input().split()))
ai2 = sorted(ai)
num = 1
num2 = ai2[0]
ans = 1
for i in range(1, n):
	if ai2[i] != ai2[i - 1]:
		if num > ans:
			ans = num
			num2 = ai2[i - 1]
		num = 1
	else:
		num += 1
if num > ans:
	ans = num
	num2 = ai2[-1]
num3 = 0
for i in range(n):
	if ai[i] == num2:
		num3 = i
		break
print(n - ans)
for i in range(num3 - 1, -1, -1):
	if ai[i] > ai[i + 1]:
		print(2, i + 1, i + 2)
	else:
		print(1, i + 1, i + 2)
	ai[i] = num2
	ai[i + 1] = num2
for i in range(num3 + 1, n):
	if ai[i] == ai[i - 1]:
		continue
	if ai[i] > ai[i - 1]:
		print(2, i + 1, i)
	else:
		print(1, i + 1, i)
	ai[i] = num2
	ai[i - 1] = num2


n = int(input())
a = list(map(int, input().split()))
count = {}
for i in a:
	count[i] = count.get(i, 0) + 1
el = 0
ma = 0
for k in count:
	if count[k] > ma:
		ma = count[k]
		el = k
ind = 0
for i in range(len(a)):
	if a[i] == el:
		ind = i
		break
if len(count) == 1:
	print(0)
else:
	print(len(a) - count[el])
	j = ind
	for i in range(ind - 1, -1, -1):
		if a[i] != el:
			if a[i] < el:
				print(1, i + 1, j + 1)
			else:
				print(2, i + 1, j + 1)
		j = i
	j = ind
	for i in range(ind + 1, len(a)):
		if a[i] != el:
			if a[i] < el:
				print(1, i + 1, j + 1)
			else:
				print(2, i + 1, j + 1)
		j = i


n = int(input())
l = list(map(int, input().strip().split()))
count = [0 for i in range(2000001)]
mx = 0
ind = 0
for i in range(n):
	count[l[i]] += 1
	if count[l[i]] > mx:
		mx = count[l[i]]
		ind = i
print(n - mx)
c = l[ind]
for j in range(ind, n):
	if l[j] > c:
		print(2, j + 1, j)
	elif l[j] < c:
		print(1, j + 1, j)
for j in range(ind, -1, -1):
	if l[j] > c:
		print(2, j + 1, j + 2)
	elif l[j] < c:
		print(1, j + 1, j + 2)


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
(popular, occurrences) = Counter(a).most_common(1)[0]
print(n - occurrences)
change = False
last = -1
for i in range(len(a)):
	if a[i] == popular and change:
		for j in range(i - 1, last, -1):
			if a[j] < popular:
				print('1 {} {}'.format(j + 1, j + 2))
			else:
				print('2 {} {}'.format(j + 1, j + 2))
	else:
		change = True
	if a[i] == popular:
		last = i
for i in range(last + 1, n):
	if popular > a[i]:
		print('1 {} {}'.format(i + 1, i))
	else:
		print('2 {} {}'.format(i + 1, i))


from collections import defaultdict as DD
from bisect import bisect_left as BL
from bisect import bisect_right as BR
from itertools import combinations as IC
from itertools import permutations as IP
from random import randint as RI
import sys
MOD = pow(10, 9) + 7

def IN(f=0):
	if f == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
n = IN(1)
a = IN(0)
ma = -1
M = -1
ind = 0
d = DD(int)
for i in range(n):
	d[a[i]] += 1
	f = d[a[i]]
	if f > ma:
		ma = f
		M = a[i]
ind = a.index(M)
ans = []
for i in range(ind - 1, -1, -1):
	if a[i] == M:
		continue
	elif a[i] > M:
		ans.append([2, i + 1, i + 2])
	else:
		ans.append([1, i + 1, i + 2])
for i in range(ind + 1, n):
	if a[i] == M:
		continue
	elif a[i] > M:
		ans.append([2, i + 1, i])
	else:
		ans.append([1, i + 1, i])
print(len(ans))
for i in ans:
	print(*i)


n = int(input())
A = list(map(int, input().split()))
A = [-1] + A
vec = [[] for i in range(200005)]
for i in range(1, n + 1):
	vec[A[i]].append(i)
(mx, num) = (0, 0)
for i in range(200005):
	mx = max(mx, len(vec[i]))
	if mx == len(vec[i]):
		num = i
ans = []
for i in range(vec[num][0] - 1, 0, -1):
	if A[i] < A[i + 1]:
		ans.append([1, i, i + 1])
	else:
		ans.append([2, i, i + 1])
	A[i] = A[i + 1]
for i in range(2, n + 1):
	if A[i] == A[i - 1]:
		continue
	elif A[i] < A[i - 1]:
		ans.append([1, i, i - 1])
	else:
		ans.append([2, i, i - 1])
	A[i] = A[i - 1]
print(len(ans))
for i in ans:
	print(i[0], i[1], i[2])


from collections import Counter
import string
import math
import sys

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(arrber_of_variables):
	if arrber_of_variables == 1:
		return int(sys.stdin.readline())
	if arrber_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
n = vary(1)
num = array_int()
tt = makedict(num)
mini = -1
for i in tt:
	if mini < tt[i]:
		value = i
		mini = tt[i]
count = 0
arr = []
for i in range(n):
	if num[i] == value:
		ind = i
mm = ind
for i in range(mm, n - 1):
	count += 1
	if num[i + 1] > num[ind]:
		num[i + 1] = num[ind]
		ind += 1
		arr.append([2, i + 2, i + 1])
	if num[i + 1] < num[ind]:
		num[i + 1] = num[ind]
		ind += 1
		arr.append([1, i + 2, i + 1])
ind = mm
for j in range(ind - 1, -1, -1):
	if num[j] < num[ind]:
		num[j] = num[ind]
		ind -= 1
		count += 1
		arr.append([1, j + 1, j + 2])
	elif num[j] > num[ind]:
		count += 1
		num[j] = num[ind]
		ind -= 1
		arr.append([2, j + 1, j + 2])
	else:
		continue
print(count)
for i in arr:
	print(*i)


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
c = defaultdict(int)
for el in a:
	c[el] += 1
(most_p, most_p_amount) = (0, 0)
for (num, amount) in c.items():
	if amount > most_p_amount:
		most_p = num
		most_p_amount = amount
operations = []
most_p_i = a.index(most_p)
for i in range(most_p_i, len(a) - 1):
	if most_p > a[i + 1]:
		operations.append((1, i + 1, i))
	if most_p < a[i + 1]:
		operations.append((2, i + 1, i))
for i in range(most_p_i, 0, -1):
	if most_p > a[i - 1]:
		operations.append((1, i - 1, i))
	if most_p < a[i - 1]:
		operations.append((2, i - 1, i))
print(len(operations))
for (op, i1, i2) in operations:
	print(op, i1 + 1, i2 + 1)


n = int(input())
a = list(map(int, input().split()))
cnt = [0] * (2 * 10 ** 5 + 1)
ind = [0] * (2 * 10 ** 5 + 1)
for i in range(n):
	cnt[a[i]] += 1
	ind[a[i]] = i
m = max(cnt)
i_m = ind[cnt.index(m)]
distinct = n - m
print(distinct)
i = i_m
for j in range(i_m + 1, n):
	if a[j] != a[i]:
		if a[j] > a[i]:
			print(2, j + 1, j)
			a[j] = a[i]
		else:
			print(1, j + 1, j)
			a[j] = a[i]
for j in range(i_m - 1, -1, -1):
	if a[j] != a[i]:
		if a[j] > a[i]:
			print(2, j + 1, j + 2)
			a[j] = a[i]
		else:
			print(1, j + 1, j + 2)
			a[j] = a[i]


n = int(input())
a = [int(i) for i in input().split()]
counts = {}
max_cnt = 0
max_value = -1
indd = -1
for ij in range(n):
	i = a[ij]
	if i not in counts:
		counts[i] = 0
	counts[i] += 1
	if counts[i] > max_cnt:
		max_cnt = counts[i]
		max_value = i
		indd = ij
print(n - max_cnt)
for i in range(indd + 1, n):
	if a[i] != max_value:
		if a[i] < max_value:
			print(1, i + 1, i)
		else:
			print(2, i + 1, i)
for i in range(indd - 1, -1, -1):
	if a[i] != max_value:
		if a[i] < max_value:
			print(1, i + 1, i + 2)
		else:
			print(2, i + 1, i + 2)


def _f(n, arr):
	number_count_map = {}
	for a in arr:
		if number_count_map.get(a, None) is None:
			number_count_map[a] = 1
		else:
			number_count_map[a] += 1
	max_number = list(number_count_map.keys())[0]
	for dict_key in list(number_count_map.keys()):
		if number_count_map[dict_key] > number_count_map[max_number]:
			max_number = dict_key
	result = []
	empties = []
	if arr[0] != max_number:
		empties.append([0, 0])
	for i in range(1, len(arr)):
		if arr[i] == max_number and arr[i - 1] != max_number:
			empties[-1][1] = i - 1
		elif arr[i] != max_number and arr[i - 1] != max_number:
			empties[-1][1] = i
		elif arr[i] != max_number and arr[i - 1] == max_number:
			empties.append([i, i])
	for e in empties:
		try:
			arr.index(max_number, e[1])
			for i in reversed(range(e[0], e[1] + 1)):
				if arr[i] > max_number:
					result.append((2, i + 1, i + 2))
				elif arr[i] < max_number:
					result.append((1, i + 1, i + 2))
		except:
			for i in range(e[0], e[1] + 1):
				if arr[i] > max_number:
					result.append((2, i + 1, i))
				elif arr[i] < max_number:
					result.append((1, i + 1, i))
	return result

def f(n, arr):
	result = _f(n, arr)
	print(len(result))
	for r in result:
		print(''.join((str(e) + ' ' for e in r)))
n = int(input())
arr = list(map(int, input().split()))
f(n, arr)


from collections import defaultdict
from operator import itemgetter
n = int(input())
a = list(map(int, input().split()))
c = defaultdict(int)
for el in a:
	c[el] += 1
most_p = sorted(c.items(), key=itemgetter(1))[-1][0]
operations = []
most_p_i = a.index(most_p)
for i in range(most_p_i, len(a) - 1):
	if most_p > a[i + 1]:
		operations.append((1, i + 1, i))
	if most_p < a[i + 1]:
		operations.append((2, i + 1, i))
for i in range(most_p_i, 0, -1):
	if most_p > a[i - 1]:
		operations.append((1, i - 1, i))
	if most_p < a[i - 1]:
		operations.append((2, i - 1, i))
print(len(operations))
for (op, i1, i2) in operations:
	print(op, i1 + 1, i2 + 1)


n = int(input())
arr = list(map(int, input().split()))
el = -1
max0 = 0
cnt = [0] * 1000000
for el in arr:
	cnt[el] += 1
for i in range(1000000):
	if cnt[i] > max0:
		el = i
		max0 = cnt[i]
for i in range(n):
	if arr[i] == el:
		pos = i
		break
print(n - cnt[el])
for i in range(pos, n - 1):
	if arr[i + 1] != el:
		if arr[i + 1] > el:
			print(2, i + 1 + 1, i + 1)
		else:
			print(1, i + 1 + 1, i + 1)
for i in range(pos, 0, -1):
	if arr[i - 1] != el:
		if arr[i - 1] > el:
			print(2, i - 1 + 1, i + 1)
		else:
			print(1, i - 1 + 1, i + 1)


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
m = 0
cc = Counter(l)
x = 0
for i in cc:
	if cc[i] > m:
		m = cc[i]
		x = i
i = l.index(x)
s = 0
t = []
for j in range(i, 0, -1):
	if l[j - 1] < l[i]:
		s += 1
		t.append([1, j, j + 1])
	elif l[j - 1] > l[i]:
		s += 1
		t.append([2, j, j + 1])
for j in range(i, n - 1):
	if l[j + 1] < l[i]:
		s += 1
		t.append([1, j + 2, j + 1])
	elif l[j + 1] > l[i]:
		s += 1
		t.append([2, j + 2, j + 1])
print(s)
for i in t:
	print(*i)


N = int(input())
A = list(map(int, input().split()))
freq = {}
for a in A:
	r = freq.get(a, 0)
	freq[a] = r + 1
sfreq = sorted(freq.items(), key=lambda x: x[1], reverse=True)
x = sfreq[0][0]
res = []
for i in range(N):
	ai = A[i]
	if ai == x:
		for j in range(i - 1, -1, -1):
			aj = A[j]
			if A[j] < x:
				res.append((1, j, j + 1))
			elif A[j] > x:
				res.append((2, j, j + 1))
		for j in range(i + 1, N):
			aj = A[j]
			if A[j] < x:
				res.append((1, j, j - 1))
			elif A[j] > x:
				res.append((2, j, j - 1))
		break
k = len(res)
print(k)
for (t, i, j) in res:
	print(t, i + 1, j + 1)


N = int(input())
arr = input()
arr = [int(x) for x in arr.split(' ')]
freq = {}
max_f = 0
max_num = 0
for num in arr:
	if num not in freq:
		freq[num] = 1
	else:
		freq[num] += 1
	if freq[num] > max_f:
		max_num = num
		max_f = freq[num]
target = max_num
tar_idx = -1
equ = N - max_f
for i in range(N):
	if arr[i] == target:
		tar_idx = i
		break
print(equ)
for i in range(tar_idx, N):
	if arr[i] < target:
		print('1', str(i + 1), str(i), sep=' ')
	if arr[i] > target:
		print('2', str(i + 1), str(i), sep=' ')
for i in range(tar_idx - 1, -1, -1):
	if arr[i] < target:
		print('1', str(i + 1), str(i + 2), sep=' ')
	if arr[i] > target:
		print('2', str(i + 1), str(i + 2), sep=' ')


n = int(input())
s = list(map(int, input().split()))
a = set(s)
t = {i: 0 for i in a}
for i in s:
	t[i] += 1
k = [i for i in t]

def f(x):
	return t[x]
a = max(k, key=f)
print(n - t[a])
m = s.index(a)
asd = list(range(m))
asd.reverse()
for i in asd:
	if s[i] == a:
		continue
	else:
		print(str(int(s[i + 1] < s[i]) + 1) + ' ' + str(i + 1) + ' ' + str(i + 2))
		s[i] = a
for i in range(m, n):
	if s[i] == a:
		continue
	else:
		print(str(int(s[i - 1] < s[i]) + 1) + ' ' + str(i + 1) + ' ' + str(i))
		s[i] = a


d = {}
n = int(input())
l = list(map(int, input().split()))
ll = sorted(l)
mid = n // 2
li = []
mx = -1
for i in l:
	d[i] = d.get(i, 0) + 1
for i in d:
	if d[i] > mx:
		mx = d[i]
		med = i
for i in range(n):
	if l[i] == med:
		ind = i
		break
for i in range(ind - 1, -1, -1):
	if l[i] > l[i + 1]:
		li.append((2, i + 1, i + 2))
	elif l[i] < l[i + 1]:
		li.append((1, i + 1, i + 2))
	l[i] = med
for i in range(ind + 1, n):
	if l[i] > l[i - 1]:
		li.append((2, i + 1, i))
	elif l[i] < l[i - 1]:
		li.append((1, i + 1, i))
	l[i] = med
print(len(li))
for i in li:
	print(*i)


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

def get_next_idx(idx, array, max_elem):
	n = len(array)
	done = False
	while idx < n and (not done):
		if array[idx] == max_elem:
			idx += 1
		else:
			done = True
	return idx

def get_next_chunk(start_idx, array, max_elem):
	chunk = list()
	n = len(array)
	done = False
	while start_idx < n and (not done):
		if array[start_idx] != max_elem:
			chunk.append((array[start_idx], start_idx))
			start_idx += 1
		else:
			done = True
	return (start_idx, chunk)

def get_operations(chunk, type, max_elem):
	operations = list()
	if type == 'left':
		for chunk_elem in chunk:
			curr_elem = chunk_elem[0]
			curr_idx = chunk_elem[1]
			if curr_elem < max_elem:
				op_type = 1
			else:
				op_type = 2
			operation = (op_type, curr_idx + 1, curr_idx - 1 + 1)
			operations.append(operation)
	else:
		for chunk_elem in chunk[::-1]:
			curr_elem = chunk_elem[0]
			curr_idx = chunk_elem[1]
			if curr_elem < max_elem:
				op_type = 1
			else:
				op_type = 2
			operation = (op_type, curr_idx + 1, curr_idx + 1 + 1)
			operations.append(operation)
	return operations
elem_counts = dict()
max_count = 0
max_elem = -1
for ai in a:
	if ai in elem_counts:
		elem_counts[ai] += 1
	else:
		elem_counts[ai] = 1
	if elem_counts[ai] > max_count:
		max_count = elem_counts[ai]
		max_elem = ai
num_ops = 0
ops = list()
if len(elem_counts) == 1:
	print(0)
else:
	idx = get_next_idx(0, a, max_elem)
	all_operations = list()
	if idx == 0:
		(idx, curr_chunk) = get_next_chunk(idx, a, max_elem)
		operations = get_operations(curr_chunk, 'right', max_elem)
		all_operations.extend(operations)
	while idx < n:
		idx = get_next_idx(idx, a, max_elem)
		(idx, curr_chunk) = get_next_chunk(idx, a, max_elem)
		operations = get_operations(curr_chunk, 'left', max_elem)
		all_operations.extend(operations)
	print(len(all_operations))
	for operation in all_operations:
		print(' '.join([str(x) for x in operation]))


n = int(input())
l = list(map(int, input().split()))
from collections import Counter
c = Counter(l)
a = 0
for (x, y) in c.most_common(1):
	a = x
l1 = []
for i in range(n):
	if l[i] == a:
		l1.append(i)
l2 = []
if l1[0] != 0:
	for i in range(l1[0] - 1, -1, -1):
		if l[i] < a:
			l2.append([1, i + 1, i + 2])
		else:
			l2.append([2, i + 1, i + 2])
if l1[-1] != n - 1:
	l1.append(n)
for i in range(len(l1) - 1):
	for j in range(l1[i] + 1, l1[i + 1]):
		if l[j] < a:
			l2.append([1, j + 1, j])
		else:
			l2.append([2, j + 1, j])
print(len(l2))
for i in l2:
	print(*i)


from collections import Counter

def solve():
	n = int(input())
	arr = list(map(int, input().split(' ')))
	highest_freq_items = Counter(arr).most_common(1)[0]
	highest_freq = highest_freq_items[1]
	highest_freq_num = highest_freq_items[0]
	if n - highest_freq == 0:
		print(0)
		return
	print(n - highest_freq)
	index = arr.index(highest_freq_num)
	for i in range(index - 1, -1, -1):
		if arr[i] == highest_freq_num:
			continue
		if arr[i] > highest_freq_num:
			print('2 {} {}'.format(i + 1, i + 2))
		else:
			print('1 {} {}'.format(i + 1, i + 2))
	for i in range(index, n):
		if arr[i] == highest_freq_num:
			continue
		if arr[i] > highest_freq_num:
			print('2 {} {}'.format(i + 1, i))
		else:
			print('1 {} {}'.format(i + 1, i))
solve()


import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
l = list(map(int, input().split(' ')))
if n == 1:
	print(0)
else:
	d = defaultdict(int)
	d_ind = defaultdict(int)
	for i in range(n):
		d_ind[l[i]] = i
		d[l[i]] += 1
	k = max(d, key=d.get)
	start = d_ind[k]
	print(n - d[k])
	for i in range(start, n):
		if l[i] > k:
			print(2, i + 1, i)
		if l[i] < k:
			print(1, i + 1, i)
	for i in range(start, -1, -1):
		if l[i] > k:
			print(2, i + 1, i + 2)
		elif l[i] < k:
			print(1, i + 1, i + 2)


n = int(input())
a = list(map(int, input().split()))
asort = sorted(a)
(maxcnt, cnt) = (1, 1)
maxelmnt = asort[0]
for i in range(n - 1):
	if asort[i] == asort[i + 1]:
		cnt += 1
		if maxcnt < cnt:
			maxcnt = cnt
			maxelmnt = asort[i]
	else:
		cnt = 1
k = maxelmnt
for i in range(n):
	if a[i] == k:
		break
fk = i
print(n - maxcnt)
for i in range(fk - 1, -1, -1):
	if a[i] == k:
		continue
	elif a[i] < k:
		print(1, i + 1, i + 2)
	else:
		print(2, i + 1, i + 2)
for i in range(fk + 1, n):
	if a[i] == k:
		continue
	elif a[i] < k:
		print(1, i + 1, i)
	else:
		print(2, i + 1, i)


n = int(input())
n1 = list(map(int, input().split()))
newdict = {}
for i in n1:
	if i in newdict.keys():
		newdict[i] += 1
	else:
		newdict[i] = 1
greatest = 0
maxi = 0
for i in newdict.keys():
	if newdict[i] > maxi:
		maxi = newdict[i]
		greatest = i
if maxi == 1:
	greatest = max(n1)
output = []
index = n1.index(greatest)
temp_index = index
if index > 0 and index < len(n1) - 1:
	while index > 0:
		item = ''
		if n1[index - 1] < greatest:
			item += '1 ' + str(index) + ' ' + str(index + 1)
			output.append(item)
			index -= 1
		elif n1[index - 1] > greatest:
			item += '2 ' + str(index) + ' ' + str(index + 1)
			index -= 1
			output.append(item)
		else:
			index -= 1
			continue
	while temp_index < len(n1) - 1:
		item = ''
		if n1[temp_index + 1] < greatest:
			item += '1 ' + str(temp_index + 2) + ' ' + str(temp_index + 1)
			output.append(item)
			temp_index += 1
		elif n1[temp_index + 1] > greatest:
			item += '2 ' + str(temp_index + 2) + ' ' + str(temp_index + 1)
			temp_index += 1
			output.append(item)
		else:
			temp_index += 1
			continue
elif temp_index == 0:
	while temp_index < len(n1) - 1:
		item = ''
		if n1[temp_index + 1] < greatest:
			item += '1 ' + str(temp_index + 2) + ' ' + str(temp_index + 1)
			output.append(item)
			temp_index += 1
		elif n1[temp_index + 1] > greatest:
			item += '2 ' + str(temp_index + 2) + ' ' + str(temp_index + 1)
			temp_index += 1
			output.append(item)
		else:
			temp_index += 1
			continue
elif index == len(n1) - 1:
	while index > 0:
		item = ''
		if n1[index - 1] < greatest:
			item += '1 ' + str(index) + ' ' + str(index + 1)
			output.append(item)
			index -= 1
		elif n1[index - 1] > greatest:
			item += '2 ' + str(index) + ' ' + str(index + 1)
			index -= 1
			output.append(item)
		else:
			index -= 1
			continue
print(len(output))
for i in output:
	print(i)


def most_freq(a):
	s = {}
	for i in range(len(a)):
		s[a[i]] = 0
	for i in range(len(a)):
		s[a[i]] += 1
	l = 0
	d = 0
	for key in s:
		if s[key] > l:
			l = s[key]
			d = key
	return d
n = int(input())
a = list(map(int, input().split()))
s = most_freq(a)
p = a.index(s)
z = []
for i in range(p, len(a) - 1):
	if a[i + 1] > a[i]:
		a[i + 1] = s
		z.append([2, i + 2, i + 1])
	elif a[i + 1] < a[i]:
		a[i + 1] = s
		z.append([1, i + 2, i + 1])
for i in range(p, 0, -1):
	if a[i] > a[i - 1]:
		a[i - 1] = s
		z.append([1, i, i + 1])
	elif a[i] < a[i - 1]:
		a[i - 1] = s
		z.append([2, i, i + 1])
print(len(z))
for i in range(len(z)):
	print(*z[i])


from sys import stdin
import math
from collections import defaultdict
input = stdin.readline
n = int(input())
l = list(map(int, input().split(' ')))
if n == 1:
	print(0)
else:
	d = defaultdict(int)
	d_ind = defaultdict(int)
	for i in range(n):
		d_ind[l[i]] = i
		d[l[i]] += 1
	k = max(d, key=d.get)
	start = d_ind[k]
	print(n - d[k])
	for i in range(start, n):
		if l[i] > k:
			print(2, i + 1, i)
		if l[i] < k:
			print(1, i + 1, i)
	for i in range(start, -1, -1):
		if l[i] > k:
			print(2, i + 1, i + 2)
		elif l[i] < k:
			print(1, i + 1, i + 2)


import sys, os, io
import math, bisect, operator
(inf, mod) = (float('inf'), 10 ** 9 + 7)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
Neo = lambda : list(map(int, input().split()))
(test,) = Neo()
A = Neo()
k = max(Counter(A).values())
t = test - k
val = 0
for (i, j) in Counter(A).items():
	if j == k:
		val = i
		break
ind = -1
for i in range(test):
	if A[i] == val:
		ind = i
		break
print(t)
i = ind - 1
while i >= 0:
	if A[i] != val:
		if A[i] < val:
			print(1, i + 1, i + 2)
		else:
			print(2, i + 1, i + 2)
	i -= 1
i = ind + 1
while i < test:
	if A[i] != val:
		if A[i] < val:
			print(1, i + 1, i)
		else:
			print(2, i + 1, i)
	i += 1


n = int(input())
l = list(map(int, input().split()))
mask = [0] * 200001
for i in range(n):
	mask[l[i]] += 1
for i in range(200001):
	mask[i] = [mask[i], i]
mask.sort(reverse=True)
cur = mask[0][1]
print(n - mask[0][0])
basis = l.index(cur)
for i in range(basis - 1, -1, -1):
	if l[i] > cur:
		print(2, i + 1, i + 2)
	elif l[i] < cur:
		print(1, i + 1, i + 2)
for i in range(basis + 1, n):
	if l[i] > cur:
		print(2, i + 1, i)
	elif l[i] < cur:
		print(1, i + 1, i)


n = int(input())
a = list(map(int, input().split()))
b = [0] * 200001
for v in a:
	b[v] += 1
commands = []
i = a.index(b.index(max(b)))
j = i - 1
while j >= 0:
	if a[j] < a[j + 1]:
		commands.append((1, j + 1, j + 1 + 1))
	else:
		commands.append((2, j + 1, j + 1 + 1))
	a[j] = a[j + 1]
	j -= 1
j = i + 1
while j < n:
	if a[j] < a[j - 1]:
		commands.append((1, j + 1, j - 1 + 1))
	elif a[j] > a[j - 1]:
		commands.append((2, j + 1, j - 1 + 1))
	a[j] = a[j - 1]
	j += 1
print(len(commands))
print('\n'.join([' '.join(list(map(str, commands[i]))) for i in range(len(commands))]))


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

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

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

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

def stringIn():
	return stdin.readline().strip()
n = intIn()
a = listIn()
if len(set(a)) == 1:
	print(0)
	exit(0)
else:
	di = {}
	mp = {}
	for i in range(1, n + 1):
		ele = a[i - 1]
		if ele not in di:
			di[ele] = 1
			mp[ele] = [i]
		else:
			di[ele] += 1
			mp[ele].append(i)
	mx = max(di.values())
	for ele in di:
		if di[ele] == mx:
			maxx = ele
			break
	op = n - mx
	pos = mp[maxx]
	ini = 0
	last = n
	print(op)
	cnt = 0
	for p in pos:
		for i in range(p - 1, ini, -1):
			if a[i - 1] > maxx:
				print(2, i, i + 1)
				cnt += 1
			else:
				print(1, i, i + 1)
				cnt += 1
		ini = p
		if cnt == op:
			break
	if pos[len(pos) - 1] != n:
		for i in range(ini, n, 1):
			if a[i] > maxx:
				print(2, i + 1, i)
				cnt += 1
			else:
				print(1, i + 1, i)
				cnt += 1
			if cnt == op:
				break


import sys
n = int(input())
arr = list(map(int, input().split()))
noCounts = [0] * (2 * 10 ** 5 + 1)
for i in arr:
	noCounts[i] += 1
tmp = max(noCounts)
print(n - tmp)
x = noCounts.index(tmp)
a = arr.index(x)
for i in range(a, 0, -1):
	if arr[i] < arr[i - 1]:
		print(2, i, i + 1)
		arr[i - 1] = arr[i]
	else:
		print(1, i, i + 1)
		arr[i - 1] = arr[i]
for i in range(a, n - 1):
	if arr[i] < arr[i + 1]:
		print(2, i + 2, i + 1)
		arr[i + 1] = arr[i]
	elif arr[i] == arr[i + 1]:
		continue
	else:
		print(1, i + 2, i + 1)
		arr[i + 1] = arr[i]


from collections import *
n = int(input())
l = list(map(int, input().split()))
c = Counter(l)
inverse = [(value, key) for (key, value) in c.items()]
m = int(max(inverse)[1])
a = int(l.index(m))
b = int(c[m] + a - 1)
print(n - int(c[m]))
for i in range(a - 1, -1, -1):
	if l[i] > m:
		print(2, end=' ')
		print(i + 1, end=' ')
		print(i + 2)
	elif l[i] < m:
		print(1, end=' ')
		print(i + 1, end=' ')
		print(i + 2)
for i in range(a + 1, n):
	if l[i] > m:
		print(2, end=' ')
		print(i + 1, end=' ')
		print(i)
	elif l[i] < m:
		print(1, end=' ')
		print(i + 1, end=' ')
		print(i)


MOD = 10 ** 9 + 7
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n = ii()
l = il()
lnum = [0] * (2 * 10 ** 5 + 10)
for i in l:
	lnum[i] += 1
mx = 0
for i in range(2 * 10 ** 5 + 5):
	if lnum[i] > mx:
		mx = lnum[i]
		num = i
ind = l.index(num)
print(n - mx)
for i in range(ind - 1, -1, -1):
	if l[i] < l[i + 1]:
		l[i] = l[i + 1]
		print(1, i + 1, i + 2)
	elif l[i] > l[i + 1]:
		l[i] = l[i + 1]
		print(2, i + 1, i + 2)
for i in range(ind + 1, n):
	if l[i - 1] < l[i]:
		print(2, i + 1, i)
		l[i] = l[i - 1]
	elif l[i - 1] > l[i]:
		l[i] = l[i - 1]
		print(1, i + 1, i)


from collections import Counter

def solve(values):
	counts = Counter(values)
	((max_value, _),) = counts.most_common(1)
	max_index = values.index(max_value)
	ops = []
	for i in reversed(range(max_index)):
		op = 2 if values[i] > max_value else 1
		ops.append((op, i, i + 1))
	index = max_index + 1
	while index < len(values):
		if values[index] == max_value:
			index += 1
			continue
		op = 2 if values[index] > max_value else 1
		ops.append((op, index, index - 1))
		index += 1
	return ops

def main() -> None:
	n = int(input())
	values = list(map(int, input().split()))
	ops = solve(values)
	print(len(ops))
	for (t, i, j) in ops:
		print(t, i + 1, j + 1)
main()


from collections import *
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
m = 0
ind = 0
for i in range(len(a)):
	if c[a[i]] > m:
		m = c[a[i]]
		ind = i
print(n - m)
for i in range(ind, 0, -1):
	if a[i - 1] == a[ind]:
		continue
	if a[i - 1] > a[ind]:
		print(2, i, i + 1)
	else:
		print(1, i, i + 1)
for i in range(ind, n - 1):
	if a[i + 1] == a[ind]:
		continue
	if a[i + 1] > a[ind]:
		print(2, i + 2, i + 1)
	else:
		print(1, i + 2, i + 1)


from collections import Counter

def mf(List):
	occurence_count = Counter(List)
	return occurence_count.most_common(1)[0][0]
n = int(input())
a = list(map(int, input().split()))
m = mf(a)
cm = a.count(m)
print(n - cm)
ind = a.index(m)
i = ind
if i:
	while i > 0:
		j = i - 1
		if a[i] == a[j]:
			i -= 1
			continue
		elif a[j] > a[i]:
			print('2', end=' ')
		else:
			print('1', end=' ')
		a[j] = a[i]
		print(j + 1, i + 1)
		i -= 1
i = ind
if i != n - 1:
	while i < n - 1:
		j = i + 1
		if a[i] == a[j]:
			i += 1
			continue
		elif a[i] > a[j]:
			print('1', end=' ')
		else:
			print('2', end=' ')
		a[j] = a[i]
		print(j + 1, i + 1)
		i += 1


from collections import Counter
n = int(input())
A = list(map(int, input().split()))
c = Counter(A)
m = c.most_common()[0][0]
idx = -1
for i in range(len(A)):
	a = A[i]
	if a == m:
		idx = i
		break
midx = idx
steps = []
for i in range(midx, -1, -1):
	if i == idx:
		continue
	if A[i] > m:
		steps.append((2, i + 1, idx + 1))
	if A[i] < m:
		steps.append((1, i + 1, idx + 1))
	idx = i
for i in range(midx, len(A)):
	if i == idx:
		continue
	if A[i] > m:
		steps.append((2, i + 1, idx + 1))
	elif A[i] < m:
		steps.append((1, i + 1, idx + 1))
	idx = i
print(len(steps))
for step in steps:
	print(str(step[0]) + ' ' + str(step[1]) + ' ' + str(step[2]))


n = int(input())
arr = [int(x) for x in input().split()]
d = {}
for i in arr:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
maxi = 0
for i in d:
	if d[i] >= maxi:
		maxi = d[i]
		ele = i
if True:
	mid = arr.index(ele)
	ans = []
	for i in range(mid - 1, -1, -1):
		if arr[i] > arr[mid]:
			ans.append([2, i + 1, i + 2])
		elif arr[i] < arr[mid]:
			ans.append([1, i + 1, i + 2])
	for i in range(mid + 1, n):
		if arr[i] > arr[mid]:
			ans.append([2, i + 1, i])
		elif arr[i] < arr[mid]:
			ans.append([1, i + 1, i])
print(len(ans))
for i in ans:
	print(i[0], i[1], i[2])


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
cnt = defaultdict(int)
for v in a:
	cnt[v] += 1
pos = a.index(max(cnt.keys(), key=lambda x: cnt[x]))
ret = []
for i in range(pos - 1, -1, -1):
	if a[i] != a[i + 1]:
		ret.append('%d %d %d' % (1 if a[i] < a[i + 1] else 2, i + 1, i + 2))
		a[i] = a[i + 1]
for i in range(pos + 1, n):
	if a[i] != a[i - 1]:
		ret.append('%d %d %d' % (1 if a[i] < a[i - 1] else 2, i + 1, i))
		a[i] = a[i - 1]
print('%d\n%s' % (len(ret), '\n'.join(ret)))


n = int(input())
arr = list(map(int, input().split()))
from collections import Counter as ct
act = ct(arr)
maxcount = max(act.values())
if len(act) == 1:
	print(0)
else:
	print(n - maxcount)
	invact = {v: k for (k, v) in act.items()}
	maxel = invact[maxcount]
	elindex = arr.index(maxel)
	for i in reversed(range(elindex)):
		if arr[i + 1] > arr[i]:
			print(1, i + 1, i + 2)
			arr[i] = arr[i + 1]
		else:
			print(2, i + 1, i + 2)
			arr[i] = arr[i + 1]
	for j in range(elindex, n - 1):
		if arr[j] != arr[j + 1]:
			if arr[j] < arr[j + 1]:
				print(2, j + 2, j + 1)
				arr[j + 1] = arr[j]
			else:
				print(1, j + 2, j + 1)
				arr[j + 1] = arr[j]


n = int(input())
m = list(map(int, input().split()))
l = [0] * (2 * 10 ** 5 + 3)
l1 = [[] for i in range(2 * 10 ** 5 + 1)]
ma = 0
a = 0
ansm = []
ans = 0
for i in range(n):
	l[m[i]] += 1
	l1[m[i]].append(i)
	if l[m[i]] > a:
		ma = m[i]
		a = l[m[i]]
for j in range(l1[ma][0] - 1, -1, -1):
	ans += 1
	if m[j] < m[j + 1]:
		m[j] += abs(m[j + 1] - m[j])
		ansm.append([1, j + 1, j + 2])
	else:
		m[j] -= abs(m[j + 1] - m[j])
		ansm.append([2, j + 1, j + 2])
for i in range(a - 1):
	for j in range(l1[ma][i], l1[ma][i + 1] - 1):
		ans += 1
		if m[j] > m[j + 1]:
			m[j + 1] += abs(m[j + 1] - m[j])
			ansm.append([1, j + 2, j + 1])
		else:
			m[j + 1] -= abs(m[j + 1] - m[j])
			ansm.append([2, j + 2, j + 1])
ans += max(0, n - 1 - l1[ma][-1])
for j in range(l1[ma][-1], n - 1):
	if m[j] > m[j + 1]:
		m[j + 1] += abs(m[j + 1] - m[j])
		ansm.append([1, j + 2, j + 1])
	else:
		m[j + 1] -= abs(m[j + 1] - m[j])
		ansm.append([2, j + 2, j + 1])
print(ans)
for i in ansm:
	print(*i)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
import bisect
from heapq import *
from math import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

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

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

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

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

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	n = int(inp())
	a = lis()
	cnt = {}
	for i in range(0, n):
		if a[i] in cnt:
			cnt[a[i]] += 1
		else:
			cnt[a[i]] = 1
	mx = -1
	count = 0
	for i in cnt:
		if cnt[i] > count:
			mx = i
			count = cnt[i]
	ind = a.index(mx)
	print(n - count)
	i = ind
	while i >= 0:
		if a[i] == mx:
			i -= 1
			continue
		if a[i] > mx:
			print(2, i + 1, i + 2)
		if a[i] < mx:
			print(1, i + 1, i + 2)
		i -= 1
	i = ind
	while i < n:
		if a[i] == mx:
			i += 1
			continue
		if a[i] > mx:
			print(2, i + 1, i)
		if a[i] < mx:
			print(1, i + 1, i)
		i += 1
testcase(1)


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
(q, e) = Counter(a).most_common(1)[0]
print(n - e)
w = a.index(q)
for i in range(w - 1, -1, -1):
	if a[i] != q:
		print(1 if a[i] < q else 2, i + 1, i + 2)
for i in range(w + 1, n):
	if a[i] != q:
		print(1 if a[i] < q else 2, i + 1, i)


n = int(input())
a = list(map(int, input().split()))
f = dict()
for x in a:
	if x in f:
		f[x] += 1
	else:
		f[x] = 1
max_val = 0
who = 0
for (key, value) in f.items():
	if value > max_val:
		max_val = value
		who = key
ind = -1
ans = []
for j in range(0, len(a)):
	if a[j] == who:
		ind = j
		break
assert ind != -1
for j in range(ind + 1, len(a)):
	if a[j] == who:
		continue
	if a[j] > who:
		ans.append((2, j, j - 1))
	else:
		ans.append((1, j, j - 1))
for j in range(ind - 1, -1, -1):
	if a[j] == who:
		continue
	if a[j] > who:
		ans.append((2, j, j + 1))
	else:
		ans.append((1, j, j + 1))
print(len(ans))
for (t, i, j) in ans:
	print(t, i + 1, j + 1)


n = int(input())
a = list(map(int, input().split()))
d = {}
mx = 0
q = 0
ans = []
for i in a:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
	if d[i] > q:
		q = d[i]
		mx = i
for i in range(n):
	if a[i] == mx:
		ind = i
		break
print(n - d[mx])
for i in range(ind - 1, -1, -1):
	if mx > a[i]:
		print(1, i + 1, i + 2)
	elif mx < a[i]:
		print(2, i + 1, i + 2)
for i in range(ind + 1, n):
	if mx > a[i]:
		print(1, i + 1, i)
	elif mx < a[i]:
		print(2, i + 1, i)


a = int(input())
A = list(map(int, input().split()))
B = [0] * (max(A) + 1)
for i in range(a):
	B[A[i]] += 1
q = B.index(max(B))
c = B[q]
b = A.index(q)
print(a - c)
i = b - 1
while i >= 0:
	if A[i] < q:
		print(1, i + 1, i + 2)
	else:
		print(2, i + 1, i + 2)
	i -= 1
while b < a - 1:
	if A[b + 1] < q:
		print(1, b + 2, b + 1)
	elif A[b + 1] > q:
		print(2, b + 2, b + 1)
	b += 1


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
d = Counter(l)
mxc = 0
mx = 0
for i in d:
	if d[i] > mxc:
		mx = i
		mxc = d[i]
idx = []
for i in range(n):
	if l[i] == mx:
		idx.append(i)
ans = []
c = 0
for i in range(idx[0] - 1, -1, -1):
	if l[i] == mx:
		continue
	elif l[i] > mx:
		ans.append((2, i + 1, i + 2))
	else:
		ans.append((1, i + 1, i + 2))
for i in range(1, len(idx)):
	for j in range(idx[i], idx[i - 1], -1):
		if l[j] == mx:
			continue
		elif l[j] > mx:
			ans.append((2, j + 1, j + 2))
		else:
			ans.append((1, j + 1, j + 2))
for j in range(idx[-1] + 1, n):
	if l[j] == mx:
		continue
	elif l[j] > mx:
		ans.append((2, j + 1, j))
	else:
		ans.append((1, j + 1, j))
print(len(ans))
for i in ans:
	print(*i)


n = int(input())
a = list(map(int, input().split()))
d = dict()
target = 0
count_max = 0
for i in range(n):
	c = d.get(a[i], 0)
	c += 1
	d[a[i]] = c
	if count_max < c:
		count_max = c
		target = a[i]
first = 0
for i in range(n):
	if a[i] == target:
		first = i
		break
print(n - count_max)
for i in range(first - 1, -1, -1):
	if a[i] > target:
		print(str(2) + ' ' + str(i + 1) + ' ' + str(i + 2))
	elif a[i] < target:
		print(str(1) + ' ' + str(i + 1) + ' ' + str(i + 2))
for i in range(first + 1, n):
	if a[i] > target:
		print(str(2) + ' ' + str(i + 1) + ' ' + str(i))
	elif a[i] < target:
		print(str(1) + ' ' + str(i + 1) + ' ' + str(i))


n = int(input())
a = [int(i) for i in input().split()]
c = [0 for i in range(200005)]
firsts = [n for i in range(200005)]
(m, x) = (0, 0)
for j in range(n):
	i = a[j]
	c[i] += 1
	if c[i] > m:
		m = c[i]
		x = i
	if firsts[i] > j:
		firsts[i] = j
print(n - m)
for i in range(firsts[x], 0, -1):
	j = i - 1
	l = a[j]
	r = a[i]
	if l > r:
		print(2, j + 1, i + 1)
	else:
		print(1, j + 1, i + 1)
	a[j] = x
for i in range(firsts[x], n - 1):
	j = i + 1
	l = a[i]
	r = a[j]
	if l == r:
		continue
	elif r > l:
		print(2, j + 1, i + 1)
	else:
		print(1, j + 1, i + 1)
	a[j] = x


from collections import defaultdict
n = int(input())
l = list(map(int, input().strip().split(' ')))
d = defaultdict(lambda : 0)
index = -1
maximum = -1
for i in range(n):
	d[l[i]] += 1
	if d[l[i]] > d[maximum]:
		index = i
		maximum = l[i]
new_list = []
op_count = n - d[l[index]]
for j in range(index - 1, -1, -1):
	if l[j] < maximum:
		new_list.append((1, j, j + 1))
	elif l[j] > maximum:
		new_list.append((2, j, j + 1))
for j in range(index + 1, n, 1):
	if l[j] < maximum:
		new_list.append((1, j, j - 1))
	elif l[j] > maximum:
		new_list.append((2, j, j - 1))
print(op_count)
for i in new_list:
	print(i[0], i[1] + 1, i[2] + 1, sep=' ')


n = int(input())
l = list(map(int, input().split()))
d = {}
for i in l:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
m = 0
for i in d:
	if d[i] > m:
		x = i
		m = d[i]
dp = []
for i in range(len(l)):
	if l[i] == x:
		dp.append(i)
t = -1
ans = []
for i in range(len(dp)):
	t1 = dp[i]
	for h in range(t1 - 1, t, -1):
		if l[h] < x:
			ans.append([1, h + 1, h + 2])
		else:
			ans.append([2, h + 1, h + 2])
	t = t1
for c in range(dp[-1] + 1, len(l)):
	if l[c] < x:
		ans.append([1, c + 1, c])
	else:
		ans.append([2, c + 1, c])
print(len(ans))
for i in ans:
	print(*i)


import collections
n = int(input())
a = list(map(int, input().split()))
count = collections.Counter(a)
maxnumber = count.most_common()[0][0]
maxcount = count.most_common()[0][1]
print(n - maxcount)
for i in range(n):
	if a[i] == maxnumber:
		index = i
		break
for i in range(index - 1, -1, -1):
	if a[i + 1] - a[i] == 0:
		continue
	elif a[i + 1] - a[i] > 0:
		a[i] = a[i + 1]
		print(1, i + 1, i + 2)
	else:
		a[i] = a[i + 1]
		print(2, i + 1, i + 2)
for i in range(index, n - 1):
	if a[i + 1] - a[i] == 0:
		continue
	elif a[i + 1] - a[i] > 0:
		a[i + 1] = a[i]
		print(2, i + 2, i + 1)
	else:
		a[i + 1] = a[i]
		print(1, i + 2, i + 1)


from collections import Counter
N = int(input())
ls = list(map(int, input().split()))
d = dict(Counter(ls))
M = max(d.values())
for (k, v) in d.items():
	if v == M:
		main = k
		break
indices = []
for i in range(N):
	if ls[i] == main:
		indices.append(i)
print(N - M)
tot = len(indices) - 1
for i in range(tot):
	for j in range(indices[i + 1] - 1, indices[i], -1):
		if ls[j] < main:
			print(1, j + 1, j + 2)
		elif ls[j] > main:
			print(2, j + 1, j + 2)
for j in range(indices[-1] + 1, N):
	if ls[j] < main:
		print(1, j + 1, j)
	elif ls[j] > main:
		print(2, j + 1, j)
for j in range(indices[0] - 1, -1, -1):
	if ls[j] < main:
		print(1, j + 1, j + 2)
	elif ls[j] > main:
		print(2, j + 1, j + 2)


GI = lambda : int(input())
GIS = lambda : map(int, input().split())
LGIS = lambda : list(GIS())
from collections import Counter

def main():
	GI()
	xs = LGIS()
	ctr = Counter(xs)
	if len(ctr) < 2:
		print(0)
		return
	l = [(v, k) for (k, v) in ctr.items()]
	(c, m) = max(l)
	i = xs.index(m)
	print(len(xs) - c)
	for j in range(i + 1, len(xs)):
		if xs[j] == m:
			continue
		print('%i %i %i' % (1 if xs[j] < m else 2, j + 1, j))
	for j in range(i - 1, -1, -1):
		if xs[j] == m:
			continue
		print('%i %i %i' % (1 if xs[j] < m else 2, j + 1, j + 2))
main()


from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
d = {}
for i in arr:
	d[i] = d.get(i, 0) + 1
d = sorted(d.items(), key=lambda x: x[1])
e = d[-1][0]
minn = -1
for i in range(n):
	if arr[i] == e:
		minn = i
		break
ans = []
flag = False
for i in range(minn, n):
	if i + 1 < n and arr[i + 1] > e:
		ans.append([2, i + 2, i + 1])
	if i + 1 < n and arr[i + 1] < e:
		ans.append([1, i + 2, i + 1])
for j in range(minn, -1, -1):
	if j - 1 >= 0 and arr[j - 1] > e:
		ans.append([2, j, j + 1])
	elif j - 1 >= 0 and arr[j - 1] < e:
		ans.append([1, j, j + 1])
print(len(ans))
for i in ans:
	print(*i)


n = int(input())
l = list(map(int, input().split()))
dict = {}
for i in l:
	try:
		dict[i] += 1
	except:
		dict[i] = 1
maks = 0
eleman = 0
for i in dict:
	if dict[i] > maks:
		maks = dict[i]
		eleman = i
indeks = []
for i in range(n):
	if l[i] == eleman:
		indeks.append(i)
print(n - maks)
k = indeks[0]
while k - 1 > -1:
	if l[k - 1] < eleman:
		print(1, k, k + 1)
	elif l[k - 1] > eleman:
		print(2, k, k + 1)
	k -= 1
for i in range(1, maks):
	t = indeks[i]
	while t - 1 > indeks[i - 1]:
		if l[t - 1] < eleman:
			print(1, t, t + 1)
		elif l[t - 1] > eleman:
			print(2, t, t + 1)
		t -= 1
k = indeks[-1]
while k + 1 < n:
	if l[k + 1] < eleman:
		print(1, k + 2, k + 1)
	elif l[k + 1] > eleman:
		print(2, k + 2, k + 1)
	k += 1


from collections import Counter
n = int(input())
d = list(map(int, input().split()))
c = Counter(d)
m = max(c.values())
print(n - m)
scan = True
for (i, v) in enumerate(d):
	if scan:
		if c[v] == m:
			vm = v
			scan = False
			for k in range(i + 1, 0, -1):
				if d[k - 1] > vm:
					print(2, k, k + 1)
				elif d[k - 1] < vm:
					print(1, k, k + 1)
	elif v > vm:
		print(2, i + 1, i)
	elif v < vm:
		print(1, i + 1, i)


import sys
input = sys.stdin.readline
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
(x, y) = counter.most_common(1)[0]
print(n - y)
for i in range(n):
	if A[i] == x:
		start = i
		break
for j in range(start, -1, -1):
	if A[j] == x:
		continue
	if A[j] > x:
		print(2, j + 1, j + 2)
	else:
		print(1, j + 1, j + 2)
for j in range(start, n):
	if A[j] == x:
		continue
	if A[j] > x:
		print(2, j + 1, j)
	else:
		print(1, j + 1, j)


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
cpt = Counter(l)
m = cpt.most_common(1)[0][0]
i = l.index(m)
j = i + 1
ans = []
k = 0
while j < n:
	if l[j] == m:
		j += 1
	elif l[j] > m:
		ans.append([2, j + 1, j])
		k += 1
		j += 1
	else:
		ans.append([1, j + 1, j])
		k += 1
		j += 1
j = i - 1
while j > -1:
	if l[j] == m:
		j -= 1
	if l[j] > m:
		ans.append([2, j + 1, j + 2])
		k += 1
		j -= 1
	else:
		ans.append([1, j + 1, j + 2])
		k += 1
		j -= 1
print(k)
for t in ans:
	print(*t)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in range(n):
		if d.get(a[i]) == None:
			d[a[i]] = 1
		else:
			d[a[i]] += 1
	mxCnt = 0
	mx = 0
	for x in d:
		if d[x] > mxCnt:
			mxCnt = d[x]
			mx = x
	index = -1
	for i in range(n):
		if a[i] == mx:
			index = i
			break
	print(n - mxCnt)
	for i in range(index + 1, n):
		if a[i] < mx:
			print('1', i + 1, i)
		elif a[i] > mx:
			print('2', i + 1, i)
	for i in range(index - 1, -1, -1):
		if a[i] < mx:
			print('1', i + 1, i + 2)
		elif a[i] > mx:
			print('2', i + 1, i + 2)
	return
	return
main()


n = int(input())
a = [int(x) for x in input().split()]
d = {}
for ai in a:
	d[ai] = d[ai] + 1 if d.get(ai) else 1
mai = max(d, key=d.get)
mi = a.index(mai)
s = []
x = 1
while True:
	f1 = False
	f2 = False
	if mi - x >= 0:
		f1 = True
		if a[mi - x] > mai:
			s.append(f'2 {mi - x + 1} {mi - x + 2}')
		else:
			s.append(f'1 {mi - x + 1} {mi - x + 2}')
		a[mi - x] = mai
	if mi + x < n:
		f2 = True
		if a[mi + x] > mai:
			s.append(f'2 {mi + x + 1} {mi + x}')
		elif a[mi + x] < mai:
			s.append(f'1 {mi + x + 1} {mi + x}')
		a[mi + x] = mai
	if not f1 and (not f2):
		break
	else:
		x += 1
print(len(s))
for each in s:
	print(each)


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
m = max(c, key=c.get)
x = a.index(m)
print(n - c[m])
for i in range(x - 1, -1, -1):
	if a[i] == m:
		continue
	if a[i] < m:
		print(1, i + 1, i + 2)
	else:
		print(2, i + 1, i + 2)
for i in range(x + 1, n):
	if a[i] == m:
		continue
	if a[i] < m:
		print(1, i + 1, i)
	else:
		print(2, i + 1, i)


n = int(input())
array = input()
A = [int(x) for x in array.split()]
newA = A[:]

def convert(a, b):
	if a >= b:
		ans = 2
	else:
		ans = 1
	return ans
if n == 1:
	print(0)
else:
	newA.sort()
	maxi = 0
	counter = 1
	current = newA[0]
	repeated = newA[0]
	for i in range(1, n):
		if newA[i] == current:
			counter += 1
		else:
			if maxi < counter:
				maxi = counter
				repeated = current
			counter = 1
			current = newA[i]
	if maxi < counter:
		maxi = counter
		repeated = current
	print(n - maxi)
	found = False
	for i in range(n):
		if A[i] == repeated and (not found):
			index = i
			found = True
	for i in range(index, n):
		if A[i] != repeated:
			operation = [convert(A[i], repeated), i + 1, i]
			print(' '.join([str(x) for x in operation]))
	for i in range(index):
		operation = [convert(A[index - i - 1], repeated), index - i, index - i + 1]
		print(' '.join([str(x) for x in operation]))


n = int(input())
nums = input().split()
nums = list(map(int, nums))
count = {}
for i in nums:
	count[i] = count.get(i, 0) + 1
max_ = 0
for i in count:
	if count[i] > max_:
		max_ = count[i]
		maxNum = i
if max_ == n:
	print(0)
else:
	print(n - max_)
	for i in range(n):
		if nums[i] == maxNum:
			break
	if i > 0:
		for j in range(i - 1, -1, -1):
			if nums[j] > maxNum:
				print('2 ' + str(j + 1) + ' ' + str(j + 2))
			if nums[j] < maxNum:
				print('1 ' + str(j + 1) + ' ' + str(j + 2))
	while i + 1 < n:
		i += 1
		if nums[i] == maxNum:
			continue
		if nums[i] > maxNum:
			opt = '2'
		else:
			opt = '1'
		print(opt + ' ' + str(i + 1) + ' ' + str(i))


n = int(input())
a = list(map(int, input().split()))
x = a[0]
if a.count(x) == n:
	print(0)
else:
	r = [[a[i], i] for i in range(n)]
	r.sort()
	f = {}
	mv = 0
	ans = []
	for i in a:
		if i in f:
			f[i] += 1
		else:
			f[i] = 1
	x = max(f.values())
	ind = 0
	for i in f.keys():
		if f[i] == x:
			ind = i
			break
	i = a.index(ind)
	for j in range(i + 1, n):
		if a[j] > a[j - 1]:
			a[j] = a[j - 1]
			ans.append([2, j + 1, j])
			mv += 1
		elif a[j] < a[j - 1]:
			a[j] = a[j - 1]
			ans.append([1, j + 1, j])
			mv += 1
	for j in range(i - 1, -1, -1):
		if a[j] > a[j + 1]:
			a[j] = a[j + 1]
			ans.append([2, j + 1, j + 2])
			mv += 1
		elif a[j] < a[j + 1]:
			a[j] = a[j + 1]
			ans.append([1, j + 1, j + 2])
			mv += 1
	print(mv)
	for i in ans:
		print(*i)


n = int(input())
num = [int(x) for x in input().split(' ')]
help = dict()
used = set()
for i in range(n):
	if num[i] not in used:
		help[num[i]] = 1
		used.add(num[i])
	else:
		help[num[i]] += 1
w = 0
for i in range(n):
	c = help[num[i]]
	if c > w:
		w = c
		ans = num[i]
		h = i
ans = num[h]
print(n - w)
for i in range(h, -1, -1):
	if num[i] > ans:
		print(2, i + 1, i + 2)
	elif num[i] < ans:
		print(1, i + 1, i + 2)
for i in range(h, n, 1):
	if num[i] > ans:
		print(2, i + 1, i)
	elif num[i] < ans:
		print(1, i + 1, i)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

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

def msi():
	return map(str, input().strip().split(' '))

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

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scan_int = lambda : int(input())
scan_string = lambda : input().rstrip()
read_list = lambda : list(read())
read = lambda : map(int, input().split())
read_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

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

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

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

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

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

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

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(beauty, s, n, count):
	pass
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect

def solve():
	n = scan_int()
	a = read_list()
	if len(list(set(a))) == 1:
		print(0)
		return
	mp = {}
	val = -1
	lastx = -1
	m = 0
	val = []
	for (i, x) in enumerate(a):
		d = mp.get(x, 0)
		mp[x] = d + 1
		val.append([d + 1, x, i])
	val.sort()
	ind = val[-1][-1]
	m = val[-1][1]
	ans = []
	for i in range(ind - 1, -1, -1):
		if a[i] == m:
			continue
		if a[i] < m:
			ans.append([1, i + 1, i + 2])
		else:
			ans.append([2, i + 1, i + 2])
	for i in range(ind + 1, n):
		if a[i] == m:
			continue
		if a[i] < m:
			ans.append([1, i + 1, i])
		else:
			ans.append([2, i + 1, i])
	print(len(ans))
	for x in ans:
		print(*x)
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for i in range(1):
	solve()


from sys import stdin, stdout
from collections import Counter
for _ in range(1):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	v = Counter(a).most_common()[0][0]
	ind = []
	for i in range(n):
		if a[i] == v:
			ind += [i]
	print(n - len(ind))
	p = ind[0]
	while p > 0:
		if a[p - 1] < v:
			print(1, p, p + 1)
		else:
			print(2, p, p + 1)
		p -= 1
	for (p1, p2) in zip(ind, ind[1:]):
		p = p1
		while p + 1 < p2:
			if a[p + 1] > v:
				print(2, p + 2, p + 1)
			else:
				print(1, p + 2, p + 1)
			p += 1
	p = ind[-1]
	while p + 1 < n:
		if a[p + 1] > v:
			print(2, p + 2, p + 1)
		else:
			print(1, p + 2, p + 1)
		p += 1


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
d = Counter(l)
d = d.most_common()
temp = d[0][0]
j = l.index(temp)
count = 0
ans = []
for i in range(j - 1, -1, -1):
	if l[i] < temp:
		count += 1
		ans.append([1, i + 1, i + 2])
	elif l[i] > temp:
		ans.append([2, i + 1, i + 2])
		count += 1
for i in range(j + 1, n):
	if l[i] < temp:
		count += 1
		ans.append([1, i + 1, i])
	elif l[i] > temp:
		count += 1
		ans.append([2, i + 1, i])
print(count)
for i in ans:
	for j in i:
		print(j, end=' ')
	print()


n = int(input())
numbers = list(map(int, input().split()))
frequency = {}
for i in numbers:
	if i in frequency:
		frequency[i] += 1
	else:
		frequency[i] = 1
items = list(frequency.items())
items.sort(key=lambda x: x[1])
m = items[-1][0]
index = numbers.index(m)
res = []
for i in range(index, 0, -1):
	if numbers[i - 1] == numbers[i]:
		continue
	elif numbers[i - 1] < numbers[i]:
		res.append((1, i, i + 1))
		numbers[i - 1] = numbers[i]
	elif numbers[i - 1] > numbers[i]:
		res.append((2, i, i + 1))
		numbers[i - 1] = numbers[i]
for i in range(index, n - 1):
	if numbers[i + 1] == numbers[i]:
		continue
	elif numbers[i + 1] < numbers[i]:
		res.append((1, i + 2, i + 1))
		numbers[i + 1] = numbers[i]
	elif numbers[i + 1] > numbers[i]:
		res.append((2, i + 2, i + 1))
		numbers[i + 1] = numbers[i]
print(len(res))
for i in res:
	print(i[0], i[1], i[2])


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
output = []
maxi = 0
start = -1
counts = {}
for i in range(n):
	if a[i] not in counts.keys():
		counts[a[i]] = 0
	counts[a[i]] += 1
	if counts[a[i]] > maxi:
		start = i
		maxi = counts[a[i]]
for i in range(start, 0, -1):
	if a[i - 1] < a[i]:
		a[i - 1] = a[i]
		output.append('1 ' + str(i) + ' ' + str(i + 1))
	elif a[i - 1] > a[i]:
		a[i - 1] = a[i]
		output.append('2 ' + str(i) + ' ' + str(i + 1))
for i in range(start, n - 1):
	if a[i + 1] < a[i]:
		a[i + 1] = a[i]
		output.append('1 ' + str(i + 2) + ' ' + str(i + 1))
	elif a[i + 1] > a[i]:
		a[i + 1] = a[i]
		output.append('2 ' + str(i + 2) + ' ' + str(i + 1))
print(len(output))
for line in output:
	print(line)


import sys
from collections import defaultdict as dd
from itertools import permutations as pp
from itertools import combinations as cc
from collections import Counter as ccd
from random import randint as rd
from bisect import bisect_left as bl
import heapq
mod = 10 ** 9 + 7

def ri(flag=0):
	if flag == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
n = ri(1)
a = ri()
k = dd(int)
for i in a:
	k[i] += 1
best = 0
idx = -1
for i in k:
	if k[i] > best:
		best = k[i]
		idx = i
now = a.index(idx)
ans = []
for i in range(now, 0, -1):
	if a[i - 1] != a[i]:
		if a[i - 1] < a[i]:
			ans.append((1, i - 1, i))
		else:
			ans.append((2, i - 1, i))
		a[i - 1] = a[i]
for i in range(now, n - 1):
	if a[i] != a[i + 1]:
		if a[i] < a[i + 1]:
			ans.append((2, i + 1, i))
		else:
			ans.append((1, i + 1, i))
		a[i + 1] = a[i]
print(len(ans))
for (t, i, j) in ans:
	print(t, i + 1, j + 1)


n = int(input())
l = [int(i) for i in input().split(' ')]
count = {}
for i in l:
	if i in count:
		count[i] += 1
	else:
		count[i] = 1
count_to_list = [(count[k], k) for k in count]
count_to_list.sort(reverse=True)
(most_frequent_count, most_frequent) = count_to_list[0]
move_count = n - most_frequent_count
print(move_count)
first_most_freq = None
for (i, v) in enumerate(l):
	if v == most_frequent:
		first_most_freq = i
		break
for i in range(first_most_freq - 1, -1, -1):
	a = l[i]
	if a > most_frequent:
		op = 2
	else:
		op = 1
	print('%s %s %s' % (op, i + 1, i + 2))
for i in range(first_most_freq + 1, n):
	a = l[i]
	if a == most_frequent:
		continue
	if a > most_frequent:
		op = 2
	else:
		op = 1
	print('%s %s %s' % (op, i + 1, i))


TN = 1

def solution():
	n = int(input())
	a = list(map(int, input().split()))
	klv = {}
	keys = []
	for i in a:
		try:
			x = klv[i]
		except:
			keys.append(i)
			klv[i] = 1
		else:
			klv[i] += 1
	lcur = 0
	cur = 0
	for i in keys:
		if lcur <= klv[i]:
			lcur = klv[i]
			cur = i
	ind = a.index(cur)
	k = n - klv[cur]
	print(k)
	for i in reversed(range(ind)):
		if a[i] > a[ind]:
			print(2, i + 1, i + 2)
		elif a[i] < a[ind]:
			print(1, i + 1, i + 2)
	for i in range(ind + 1, n):
		if a[i] > a[ind]:
			print(2, i + 1, i)
		elif a[i] < a[ind]:
			print(1, i + 1, i)
while TN != 0:
	solution()
	TN -= 1


n = int(input())
l = list(map(int, input().split()))
hash = {}
max = 0
ans = 0
for i in l:
	try:
		hash[i]
	except:
		hash[i] = 1
	else:
		hash[i] += 1
	if hash[i] > max:
		max = hash[i]
		ans = i
posn = []
for i in range(n):
	if l[i] == ans:
		posn.append(i)
z = posn[0]
print(n - len(posn))
for i in range(z, n - 1):
	if l[i + 1] != ans:
		if l[i + 1] > ans:
			print(2, i + 2, i + 1)
		else:
			print(1, i + 2, i + 1)
	l[i + 1] = ans
for i in range(z, 0, -1):
	if l[i - 1] != ans:
		if l[i - 1] > ans:
			print(2, i, i + 1)
		else:
			print(1, i, i + 1)
	l[i - 1] = ans


import sys
input = sys.stdin.readline
n = int(input())
c = dict()
b = list(map(int, input().split()))
for j in b:
	if j in c.keys():
		c[j] += 1
	else:
		c[j] = 1
m = -1
for j in b:
	if m <= c[j]:
		m = c[j]
		p = j
for j in range(n):
	if b[j] == p:
		r = j
d = []
for j in range(r):
	if b[j] > p:
		d.append([2, j + 1, j + 2])
	elif b[j] < p:
		d.append([1, j + 1, j + 2])
	else:
		pass
d.reverse()
for j in range(r, n):
	if b[j] > p:
		d.append([2, j + 1, j])
	elif b[j] < p:
		d.append([1, j + 1, j])
	else:
		pass
print(len(d))
for j in d:
	print(*j)


N = int(input())
a = list(map(int, input().split()))
ma = {}
for n in a:
	if n in ma:
		ma[n] += 1
	else:
		ma[n] = 1
le = -1
lo = 0
for k in ma:
	if ma[k] >= lo:
		le = k
		lo = ma[k]
df = N - lo
if df == 0:
	print(df)
	exit(0)
moves = []
print(df)
for i in range(N):
	if a[i] < le:
		moves.append((i + 1, 1))
	elif a[i] > le:
		moves.append((i + 1, 2))
	else:
		for m in reversed(moves):
			print(m[1], m[0], m[0] + 1)
		moves.clear()
for m in moves:
	print(m[1], m[0], m[0] - 1)


N = int(input())
nums = [int(i) for i in input().split(' ')]
count = dict()
m = [0, 0]
for n in nums:
	if count.get(n) is None:
		count[n] = 0
	count[n] += 1
	if count[n] > m[0]:
		m = [count[n], n]
idx = [0]
for i in range(N):
	if nums[i] == m[1]:
		idx.append(i)
print(N - m[0])
for j in range(1, m[0] + 1):
	for i in range(idx[j] - 1, idx[j - 1] - 1, -1):
		if nums[i] < m[1]:
			print('1 %d %d' % (i + 1, i + 2))
		elif nums[i] > m[1]:
			print('2 %d %d' % (i + 1, i + 2))
for i in range(idx[-1], N):
	if nums[i] < m[1]:
		print('1 %d %d' % (i + 1, i))
	elif nums[i] > m[1]:
		print('2 %d %d' % (i + 1, i))


n = int(input())
a = list(map(int, input().split()))
f = 0
import copy
for i in range(1, len(a)):
	if a[i] >= a[i - 1]:
		continue
	else:
		f = 1
		break
b = copy.deepcopy(a)
if f == 1:
	a.sort()
cnt = 1
max = 1
pos = 0
f = a[0]
for i in range(1, len(a)):
	if f == a[i]:
		cnt += 1
	else:
		f = a[i]
		cnt = 1
	if cnt > max:
		max = cnt
		pos = i
print(len(a) - max)
p1 = -1
for i in range(len(a)):
	if a[pos] == b[i]:
		p1 = i
		break
for i in range(p1 - 1, -1, -1):
	if b[i] > b[p1]:
		print(2, i + 1, i + 2)
	elif b[i] < b[p1]:
		print(1, i + 1, i + 2)
	else:
		continue
for i in range(p1 + 1, len(a)):
	if b[i] > b[p1]:
		print(2, i + 1, i)
	elif b[i] < b[p1]:
		print(1, i + 1, i)
	else:
		continue


import sys, math, queue
sys.setrecursionlimit(1000000)
n = int(input())
a = list(map(int, input().split()))
f = {}
for ai in a:
	if ai not in f:
		f[ai] = 1
	else:
		f[ai] += 1
mx = a[0]
for k in f:
	if f[k] > f[mx]:
		mx = k
del f
for i in range(n):
	if a[i] == mx:
		mxi = i
		break
steps = []
for i in range(mxi + 1, n):
	if a[i] < mx:
		steps.append((1, i + 1, i))
	elif a[i] > mx:
		steps.append((2, i + 1, i))
for i in range(mxi - 1, -1, -1):
	if a[i] < mx:
		steps.append((1, i + 1, i + 2))
	elif a[i] > mx:
		steps.append((2, i + 1, i + 2))
print(len(steps))
for step in steps:
	print(*step)


from collections import Counter
n = int(input())
a = list(map(int, input().rstrip().split()))
c = Counter(a)
maxm_number = 0
maxm_count = 0
for x in c:
	if c[x] > maxm_count:
		maxm_count = c[x]
		maxm_number = x
print(n - maxm_count)
k = 0
get_ind = a.index(maxm_number)
for i in range(get_ind - 1, -1, -1):
	if a[i] != maxm_number:
		if a[i] > maxm_number:
			print(2, i + 1, i + 2)
		else:
			print(1, i + 1, i + 2)
		a[i] = maxm_number
for i in range(get_ind + 1, n):
	if a[i] != maxm_number:
		if a[i] > maxm_number:
			print(2, i + 1, i)
		else:
			print(1, i + 1, i)
		a[i] = maxm_number


import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
from collections import Counter

def main():
	(n, *a) = map(int, read().split())
	d1 = defaultdict(int)
	a_ac = Counter(a)
	if a_ac.most_common()[0][1] == 1:
		st = a[0]
	else:
		st = a_ac.most_common()[0][0]
	stpos = a.index(st)
	r = 0
	ops = []
	if stpos:
		for j1 in range(stpos, 0, -1):
			r += 1
			if a[j1 - 1] < st:
				ops.append((1, j1, j1 + 1))
			else:
				ops.append((2, j1, j1 + 1))
	if stpos < n - 1:
		for k1 in range(stpos, n - 1):
			if st == a[k1 + 1]:
				pass
			elif st < a[k1 + 1]:
				r += 1
				ops.append((2, k1 + 2, k1 + 1))
			else:
				r += 1
				ops.append((1, k1 + 2, k1 + 1))
	print(r)
	for op in ops:
		print(*op, sep=' ')
main()


n = int(input())
num = [int(x) for x in input().split()]
dic = {}
target = -1
index = 0
for x in num:
	if x in dic:
		dic[x] += 1
		if dic[x] > dic[target]:
			target = x
	else:
		dic[x] = 1
		if target == -1:
			target = x
steps = n - dic[target]
for i in range(n):
	if num[i] == target:
		index = i
print(steps)
i = index - 1
while i >= 0:
	if num[i] < target:
		print(1, i + 1, i + 1 + 1)
	elif num[i] > target:
		print(2, i + 1, i + 1 + 1)
	i -= 1
i = index + 1
while i < n:
	if num[i] < target:
		print(1, i + 1, i)
	elif num[i] > target:
		print(2, i + 1, i)
	i += 1


import collections
n = int(input())
arr = list(map(int, input().strip().split()))
token = collections.Counter(arr)
goal = token.most_common()[0][0]
operationsCount = n - token.most_common()[0][1]
startHere = arr.index(goal)
operations = []
i = startHere
while i > 0:
	if arr[i] > arr[i - 1]:
		operations.append((1, i, i + 1))
	else:
		operations.append((2, i, i + 1))
	arr[i - 1] = goal
	i -= 1
i = startHere
while i < n - 1:
	if arr[i + 1] == goal:
		i += 1
		continue
	elif arr[i] > arr[i + 1]:
		operations.append((1, i + 2, i + 1))
	else:
		operations.append((2, i + 2, i + 1))
	arr[i + 1] = goal
	i += 1
print(operationsCount)
for operation in operations:
	print(*operation)


n = int(input())
a = list(map(int, input().split()))
d = dict()
target = 0
count_max = 0
for i in range(n):
	l = d.get(a[i])
	if l:
		l.append(i)
	else:
		l = [i]
		d[a[i]] = l
	if count_max < len(l):
		count_max = len(l)
		target = a[i]
pos_max = d[target]
print(n - len(pos_max))
pos_max.append(n)
first = pos_max[0]
for i in range(first - 1, -1, -1):
	if a[i] > a[i + 1]:
		print(str(2) + ' ' + str(i + 1) + ' ' + str(i + 2))
	elif a[i] < a[i + 1]:
		print(str(1) + ' ' + str(i + 1) + ' ' + str(i + 2))
	a[i] = a[i + 1]
for i in range(first + 1, n):
	if a[i] > a[i - 1]:
		print(str(2) + ' ' + str(i + 1) + ' ' + str(i))
	elif a[i] < a[i - 1]:
		print(str(1) + ' ' + str(i + 1) + ' ' + str(i))
	a[i] = a[i - 1]


from collections import deque, Counter
n = int(input())
a = [int(x) for x in input().split()]
freq = Counter(a)
most = freq.most_common(1)[0][0]
ind = a.index(most)
substitutions = []
for i in range(ind - 1, -1, -1):
	if a[i] > most:
		substitutions.append((2, i + 1, i + 1 + 1))
	elif a[i] < most:
		substitutions.append((1, i + 1, i + 1 + 1))
for i in range(ind + 1, n):
	if a[i] > most:
		substitutions.append((2, i + 1, i + 1 - 1))
	elif a[i] < most:
		substitutions.append((1, i + 1, i + 1 - 1))
lsubst = len(substitutions)
print(lsubst)
for subst in substitutions:
	for elem in subst:
		print(elem, end=' ')
	print()


n = input()
a = input().split()
a = [int(i) for i in a]
counter = dict()
for i in a:
	if i in counter:
		counter[i] = counter[i] + 1
	else:
		counter[i] = 1
_max = -1
target = 0
for (key, value) in counter.items():
	if value > _max:
		target = key
		_max = value
position = []
for (i, value) in enumerate(a):
	if value == target:
		position.append(i)
k = len(a) - _max
print(k)
if k > 0:
	for i in range(position[0] - 1, -1, -1):
		if a[i] > target:
			print('2 {} {}'.format(i + 1, i + 2))
		else:
			print('1 {} {}'.format(i + 1, i + 2))
	for i in range(position[0], position[-1]):
		if a[i] == target:
			continue
		elif a[i] > target:
			print('2 {} {}'.format(i + 1, i))
		else:
			print('1 {} {}'.format(i + 1, i))
	for i in range(position[-1] + 1, len(a)):
		if a[i] > target:
			print('2 {} {}'.format(i + 1, i))
		else:
			print('1 {} {}'.format(i + 1, i))


IN = input
rint = lambda : int(IN())
rlist = lambda : list(map(int, IN().split()))
n = rint()
a = rlist()
f = [0] * 2 * 10 ** 5 + [0]
for c in a:
	f[c] += 1
j = a.index(f.index(max(f)))
ans = []

def add(x, y, z):
	ans.append((x, y, z))

def check(x, y):
	if a[x] < a[y]:
		add(0, x, y)
	if a[x] > a[y]:
		add(1, x, y)
	a[x] = a[y]
while j:
	check(j - 1, j)
	j -= 1
while j + 1 - n:
	check(j + 1, j)
	j += 1
print(len(ans))
for p in ans:
	for c in p:
		print(c + 1, end=' ')
	print()


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
(c, f) = Counter(l).most_common(1)[0]
a = int(l.index(c))
print(n - f)
for i in range(a - 1, -1, -1):
	if l[i] != c:
		print(1 if l[i] < c else 2, i + 1, i + 2)
for i in range(a + 1, len(l)):
	if l[i] != c:
		print(1 if l[i] < c else 2, i + 1, i)


from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
c = Counter(arr)
(mx_key, mx_occurence) = (0, 0)
for k in c:
	if c[k] > mx_occurence:
		mx_occurence = c[k]
		mx_key = k
num_ops = n - mx_occurence
start_pos = None
for i in range(n):
	if arr[i] == mx_key:
		start_pos = i
		break
print(num_ops)
ops = []
for i in range(start_pos - 1, -1, -1):
	if arr[i] != mx_key:
		if arr[i] < mx_key:
			print('%s %s %s' % (1, i + 1, i + 2))
		else:
			print('%s %s %s' % (2, i + 1, i + 2))
for i in range(start_pos + 1, n):
	if arr[i] != mx_key:
		if arr[i] < mx_key:
			print('%s %s %s' % (1, i + 1, i))
		else:
			print('%s %s %s' % (2, i + 1, i))


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')
n = int(input())
s = list(map(int, input().split()))
d = dict()
ma = 1
ind = 0
dw = s[0]
for i in range(n):
	if s[i] not in d:
		d.update({s[i]: 1})
	else:
		d[s[i]] += 1
		if d[s[i]] > ma:
			ma = d[s[i]]
			dw = s[i]
			ind = i
print(n - ma)
for i in range(ind - 1, -1, -1):
	if s[i] == dw:
		continue
	if s[i] < s[i + 1]:
		print(1, i + 1, i + 2)
		s[i] = s[i + 1]
	else:
		print(2, i + 1, i + 2)
		s[i] = s[i + 1]
for i in range(ind + 1, n):
	if s[i] == dw:
		continue
	if s[i] < s[i - 1]:
		print(1, i + 1, i)
		s[i] = s[i - 1]
	else:
		print(2, i + 1, i)
		s[i] = s[i - 1]


import math
import bisect

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

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

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

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

def f(p=0):
	if p == 1:
		return map(int, input().split())
	elif p == 2:
		return list(map(int, input().split()))
	else:
		return int(input())
n = f()
dl = [0] * (2 * 10 ** 5 + 1)
pl = [list() for _ in range(2 * 10 ** 5 + 1)]
cl = f(2)
for i in range(n):
	dl[cl[i]] += 1
	if i == n - 1 or cl[i] != cl[i + 1]:
		pl[cl[i]].append(i)
	if i == 0 or cl[i] != cl[i - 1]:
		pl[cl[i]].append(i)
mx = max(dl)
pos = dl.index(mx)
start = pl[pos][1]
print(n - mx)
ln = len(pl[pos])
for j in range(2, ln, 2):
	x = pl[pos][j]
	for i in range(start + 1, x):
		if cl[i] > pos:
			print(2, i + 1, i)
		else:
			print(1, i + 1, i)
	if j + 1 < ln:
		start = pl[pos][j + 1]
if cl[-1] != pos:
	for i in range(pl[pos][-1] + 1, n):
		if cl[i] > pos:
			print(2, i + 1, i)
		else:
			print(1, i + 1, i)
if cl[0] != pos:
	for i in range(pl[pos][0], 0, -1):
		if cl[i - 1] > pos:
			print(2, i, i + 1)
		else:
			print(1, i, i + 1)


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	dct = {}
	k = -1
	m = 0
	for i in range(n):
		try:
			dct[arr[i]] += 1
		except:
			dct[arr[i]] = 1
		if dct[arr[i]] > m:
			m = dct[arr[i]]
			k = arr[i]
	print(n - m)
	for i in range(n):
		if arr[i] == k:
			for j in range(i - 1, -1, -1):
				if arr[j] > k:
					print(2, j + 1, j + 2)
				else:
					print(1, j + 1, j + 2)
			break
	while i != n:
		if arr[i] > k:
			print(2, i + 1, i)
		if arr[i] < k:
			print(1, i + 1, i)
		i += 1
	return 0
main()


n = int(input())
a = list(map(int, input().split()))
g = {}
for q in a:
	g[q] = g.get(q, 0) + 1
max_quantity = max(g, key=lambda x: g[x])
print(len(a) - g[max_quantity])
index_max = a.index(max_quantity)
for q in range(index_max - 1, -1, -1):
	if a[q] > max_quantity:
		print(2, q + 1, q + 2)
	else:
		print(1, q + 1, q + 2)
for q in range(index_max + 1, len(a)):
	if a[q] > max_quantity:
		print(2, q + 1, q)
	elif a[q] < max_quantity:
		print(1, q + 1, q)


n = int(input())
l = [int(e.strip()) for e in input().strip().split()]
ans = []
a = {}
for pp in l:
	if pp in a:
		a[pp] += 1
	else:
		a[pp] = 1
mx = 0
id = 0
for (i, j) in a.items():
	if j > mx:
		mx = j
		id = i
for i in range(len(l)):
	if l[i] == id:
		id = i
		break
for i in range(id + 1, len(l)):
	if l[i] > l[id]:
		ans.append((2, i, i - 1))
	elif l[i] < l[id]:
		ans.append((1, i, i - 1))
for i in range(id - 1, -1, -1):
	if l[i] > l[id]:
		ans.append((2, i, i + 1))
	elif l[i] < l[id]:
		ans.append((1, i, i + 1))
print(len(ans))
for pp in ans:
	print(pp[0], pp[1] + 1, pp[2] + 1)


def main():
	n = int(input())
	numbers = list(map(int, input().split()))
	counts = [0] * (max(numbers) + 1)
	for number in numbers:
		counts[number] += 1
	most_common_number_count = max(counts)
	print(n - most_common_number_count)
	most_common_number = counts.index(most_common_number_count)
	most_common_number_index = numbers.index(most_common_number)
	for i in range(most_common_number_index - 1, -1, -1):
		if numbers[i] > most_common_number:
			print(2, i + 1, i + 2)
		elif numbers[i] < most_common_number:
			print(1, i + 1, i + 2)
	for i in range(most_common_number_index + 1, n):
		if numbers[i] > most_common_number:
			print(2, i + 1, i)
		elif numbers[i] < most_common_number:
			print(1, i + 1, i)
main()


n = int(input())
arr = list(map(int, input().split()))
freq = [0] * 200001
point = 0
for i in range(n):
	freq[arr[i]] += 1
	if freq[arr[i]] > freq[arr[point]]:
		point = i
print(n - freq[arr[point]])
val = arr[point]
for i in range(point - 1, -1, -1):
	if arr[i] < val:
		print(1, i + 1, i + 2)
	elif arr[i] > val:
		print(2, i + 1, i + 2)
for i in range(point + 1, n):
	if arr[i] < val:
		print(1, i + 1, i)
	elif arr[i] > val:
		print(2, i + 1, i)


n = int(input())
a = [int(x) for x in input().split()]
f = set(a)
max = 0
b = [0] * 200001
for i in a:
	b[i] += 1
	if b[i] > max:
		max = b[i]
		maxr = i
for i in range(n):
	if a[i] == maxr:
		startpos = i
		break
print(n - max)
if n - max > 0:
	for i in range(startpos - 1, -1, -1):
		if a[i] == maxr:
			continue
		elif a[i] < maxr:
			print(1, i + 1, i + 2)
		else:
			print(2, i + 1, i + 2)
	for i in range(startpos + 1, n):
		if a[i] == maxr:
			continue
		elif a[i] < maxr:
			print(1, i + 1, i)
		else:
			print(2, i + 1, i)


import math
from collections import Counter
n = int(input())
ls = list(map(int, input().split()))
c = Counter(ls)
ma = 0
for i in c:
	if c[i] > ma:
		me = i
	ma = max(ma, c[i])
op = []
for i in range(n):
	if ls[i] == me:
		var = i - 1
		while var >= 0:
			if ls[var] < me:
				op.append((1, var + 1, var + 2))
			elif ls[var] > me:
				op.append((2, var + 1, var + 2))
			var -= 1
		var = i + 1
		while var < n:
			if ls[var] < me:
				op.append((1, var + 1, var))
			elif ls[var] > me:
				op.append((2, var + 1, var))
			var += 1
		break
print(len(op))
for i in op:
	print(*i)


import sys
from bisect import bisect_left, bisect_right
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log
from itertools import permutations
inf = float('inf')
mod = 1000000007
mini = 1000000007

def fact(n):
	if n == 0:
		return 1
	p = 1
	d = 10 ** 9 + 7
	for i in range(1, n + 1):
		p = p * i
		p = p % d
	return p

def ncr(n, r):
	d = 10 ** 9 + 7
	num = fact(n)
	den = fact(r) * fact(n - r) % d
	den = pow(den, d - 2, d)
	return num * den % d

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

def binary(number):
	result = 0
	while number:
		result = result + 1
		number = number & number - 1
	return result

def calculate_factors(n):
	hh = [1] * (n + 1)
	p = 2
	while p * p < n:
		if hh[p] == 1:
			for i in range(p * 2, n, p):
				hh[i] = 0
		p += 1
	total = 1
	for p in range(2, n + 1):
		if hh[p] == 1:
			count = 0
			if n % p == 0:
				while n % p == 0:
					n = int(n / p)
					count += 1
				total *= count + 1
	return total

def prime_factors(n):
	i = 2
	factors = set()
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.add(i)
	if n > 1:
		factors.add(n)
	if len(factors) == 2:
		return True
	else:
		return False

def isPrime(n):
	if n == 2 or n == 3:
		return True
	if n % 2 == 0 or n < 2:
		return False
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True

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

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

def input():
	return sys.stdin.readline().strip()
n = int(input())
Arr = get_array()
mydict = dict()
for i in Arr:
	mydict[i] = mydict.get(i, 0) + 1
maximum = 0
for i in mydict:
	if mydict[i] > maximum:
		maximum = mydict[i]
		number = i
for i in range(n):
	if Arr[i] == number:
		index = i
		break
count = 0
two = []
for i in range(index - 1, -1, -1):
	if Arr[i] > Arr[i + 1]:
		two.append(2)
		two.append(i + 1)
		two.append(i + 2)
		count = count + 1
		Arr[i] = Arr[i] - (Arr[i] - Arr[i + 1])
	elif Arr[i] < Arr[i + 1]:
		two.append(1)
		two.append(i + 1)
		two.append(i + 2)
		count = count + 1
		Arr[i] = Arr[i] + (Arr[i + 1] - Arr[i])
for i in range(index + 1, n):
	if Arr[i] > Arr[i - 1]:
		two.append(2)
		two.append(i + 1)
		two.append(i)
		count = count + 1
		Arr[i] = Arr[i] - (Arr[i] - Arr[i - 1])
	elif Arr[i] < Arr[i - 1]:
		two.append(1)
		two.append(i + 1)
		two.append(i)
		count = count + 1
		Arr[i] = Arr[i] + (Arr[i - 1] - Arr[i])
print(count)
for i in range(count):
	print(two[3 * i], two[3 * i + 1], two[3 * i + 2])


from collections import Counter
n = int(input())
a = [int(x) for x in input().split()]
c = Counter(a)
t = c.most_common(1)[0]
idx = a.index(t[0])
r = []
for i in range(idx - 1, -1, -1):
	if a[i] == t[0]:
		continue
	if a[i] > t[0]:
		r.append((2, i + 1, i + 2))
	else:
		r.append((1, i + 1, i + 2))
for i in range(idx + 1, n):
	if a[i] == t[0]:
		continue
	if a[i] > t[0]:
		r.append((2, i + 1, i))
	else:
		r.append((1, i + 1, i))
print(len(r))
for tt in r:
	print(*tt)


from collections import Counter
n = int(input())
nums = [int(s) for s in input().split(' ')]
c = Counter(nums)
(maxCount, maxNum) = (0, 0)
for num in c:
	if c[num] > maxCount:
		maxCount = c[num]
		maxNum = num
print(n - maxCount)
if n - maxCount > 0:
	i = 0
	while nums[i] != maxNum:
		i += 1
	start = i
	while i > 0:
		if nums[i - 1] < maxNum:
			print(1, i, i + 1)
		else:
			print(2, i, i + 1)
		i -= 1
	for i in range(start, n - 1):
		if nums[i + 1] < maxNum:
			print(1, i + 2, i + 1)
		elif nums[i + 1] > maxNum:
			print(2, i + 2, i + 1)


n = int(input())
a = list(map(int, input().split()))
d = {}
mv = 0
for i in range(n):
	d[a[i]] = d.get(a[i], 0) + 1
	if d[a[i]] > mv:
		mv = d[a[i]]
		mk = a[i]
		mi = i
ans = []
for i in range(mi + 1, n):
	if a[i] == mk:
		continue
	if a[i] > mk:
		ans.append((2, i + 1, i))
	else:
		ans.append((1, i + 1, i))
for i in range(mi - 1, -1, -1):
	if a[i] == mk:
		continue
	if a[i] > mk:
		ans.append((2, i + 1, i + 2))
	else:
		ans.append((1, i + 1, i + 2))
print(len(ans))
for (i, j, k) in ans:
	print(i, j, k)


n = int(input())
a = [int(x) for x in input().split()]
dic = {}
maxim = 0
for item in a:
	if item not in dic:
		dic[item] = 1
	else:
		dic[item] += 1
for item in dic:
	if dic[item] > maxim:
		maxim = dic[item]
		Item = item
k = 0
flag = False
answer = []
for item in a:
	if item == Item:
		for i in range(k - 1, -1, -1):
			if k != 0 and a[i] > a[i + 1]:
				flag = True
				answer.append([2, i + 1, i + 2])
				a[i] = a[i + 1]
			elif k != 0 and a[i] < a[i + 1]:
				flag = True
				answer.append([1, i + 1, i + 2])
				a[i] = a[i + 1]
		for i in range(k + 1, n):
			if a[i] > a[i - 1]:
				flag = True
				answer.append([2, i + 1, i])
				a[i] = a[i - 1]
			elif a[i] < a[i - 1]:
				flag = True
				answer.append([1, i + 1, i])
				a[i] = a[i - 1]
		break
	k += 1
if flag == False:
	print(0)
else:
	print(len(answer))
	for i in answer:
		print(*i)


import sys
from collections import defaultdict
lines = sys.stdin.readlines()
n = int(lines[0])
a = list(map(int, lines[1].split()))
occurences = defaultdict(int)
mx_occur_itm = n_mx_occur = -1
for i in a:
	occurences[i] += 1
for i in occurences:
	if n_mx_occur < occurences[i]:
		mx_occur_itm = i
		n_mx_occur = occurences[i]
moves = []
start = a.index(mx_occur_itm)
for i in range(start - 1, -1, -1):
	if a[i] == a[i + 1]:
		continue
	if a[i] < a[i + 1]:
		moves.append(f'1 {i + 1} {i + 2}')
		a[i] = a[i + 1]
	else:
		moves.append(f'2 {i + 1} {i + 2}')
		a[i] = a[i + 1]
for i in range(start + 1, len(a)):
	if a[i - 1] == a[i]:
		continue
	if a[i - 1] < a[i]:
		moves.append(f'2 {i + 1} {i}')
		a[i] = a[i - 1]
	else:
		moves.append(f'1 {i + 1} {i}')
		a[i] = a[i - 1]
print(len(moves))
for m in moves:
	print(m)


n = int(input())
arr = list(map(int, input().split()))
dict1 = {}
for i in range(n):
	try:
		dict1[arr[i]] += 1
	except:
		KeyError
		dict1[arr[i]] = 1
count = 0
maxval = -1
for i in dict1.keys():
	if dict1[i] > count:
		maxval = i
		count = dict1[i]
index1 = arr.index(maxval)
i = index1 - 1
ansarr = []
while i >= 0:
	if arr[i] != maxval:
		if arr[i] > maxval:
			ansarr.append('2 ' + str(i + 1) + ' ' + str(i + 2))
		else:
			ansarr.append('1 ' + str(i + 1) + ' ' + str(i + 2))
	i -= 1
i = index1 + 1
while i < n:
	if arr[i] != maxval:
		if arr[i] > maxval:
			ansarr.append('2 ' + str(i + 1) + ' ' + str(i))
		else:
			ansarr.append('1 ' + str(i + 1) + ' ' + str(i))
	i += 1
print(len(ansarr))
if len(ansarr) != 0:
	print(*ansarr)


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

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

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

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

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

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

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

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

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

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

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

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

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

def maxSubArraySum(a, size):
	max_so_far = -sys.maxsize - 1
	max_ending_here = 0
	start = 0
	end = 0
	s = 0
	for i in range(0, size):
		max_ending_here += a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
			start = s
			end = i
		if max_ending_here < 0:
			max_ending_here = 0
			s = i + 1
	return (max_so_far, start, end)

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] >= arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def solve():
	n = int(input())
	arr = list_input()
	occur = {}
	pos = {}
	for i in range(n):
		try:
			occur[arr[i]] += 1
			pos[arr[i]].append(i)
		except KeyError:
			occur[arr[i]] = 1
			pos[arr[i]] = [i]
	occur = sort_dict(occur)
	(num, _) = occur[0]
	pos = pos[num]
	print(n - _)
	prev = -1
	for i in pos:
		if prev == -1:
			j = i - 1
			while j >= 0:
				if arr[j] < num:
					print(1, j + 1, j + 2)
				else:
					print(2, j + 1, j + 2)
				j -= 1
			prev = i
		else:
			if i - prev != 1:
				j = i - 1
				while j > prev:
					if arr[j] < num:
						print(1, j + 1, j + 2)
					else:
						print(2, j + 1, j + 2)
					j -= 1
			prev = i
	if pos[-1] != n - 1:
		j = pos[-1] + 1
		while j < n:
			if arr[j] < num:
				print(1, j + 1, j)
			else:
				print(2, j + 1, j)
			j += 1
t = 1
for _ in range(t):
	solve()


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, sin, cos, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(1000000000)
INF = float('inf')
(YES, Yes, yes, NO, No, no) = ('YES', 'Yes', 'yes', 'NO', 'No', 'no')
(dy4, dx4) = ([0, 1, 0, -1], [1, 0, -1, 0])
(dy8, dx8) = ([0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1])

def inside(y, x, H, W):
	return 0 <= y < H and 0 <= x < W

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

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

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

def euclidean_distance(y1, x1, y2, x2):
	return sqrt((y1 - y2) ** 2 + (x1 - x2) ** 2)

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

def main():
	N = int(input())
	A = list(map(int, input().split()))
	c = Counter(A)
	max_num = -1
	max_freq = -1
	for (k, v) in c.items():
		if v > max_freq:
			max_freq = v
			max_num = k
	max_idx = A.index(max_num)
	ans = []
	for i in range(max_idx + 1, N):
		if A[i] == max_num:
			continue
		elif A[i] > max_num:
			ans.append((2, i, i - 1))
		else:
			ans.append((1, i, i - 1))
	for i in range(max_idx - 1, -1, -1):
		if A[i] == max_num:
			continue
		elif A[i] > max_num:
			ans.append((2, i, i + 1))
		else:
			ans.append((1, i, i + 1))
	print(len(ans))
	for (a, b, c) in ans:
		print(f'{a} {b + 1} {c + 1}')
main()


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

def find_max(all_nums):
	nums_dict = {}
	for i in all_nums:
		if i in nums_dict:
			nums_dict[i] += 1
		else:
			nums_dict[i] = 1
	max_key = max(nums_dict.keys(), key=lambda x: nums_dict.get(x))
	max_position = 0
	for i in range(len(all_nums)):
		if all_nums[i] == max_key:
			max_position = i
			break
	return (max_key, max_position)

def change_rest_elements(all_nums, max_key_max_position):
	max_key = max_key_max_position[0]
	max_position = max_key_max_position[1]
	output = []
	for i in range(max_position + 1, len(all_nums), 1):
		if all_nums[i] < max_key:
			new_i = i + 1
			j = i
			output_trio = (1, new_i, j)
			output.append(output_trio)
		elif all_nums[i] > max_key:
			new_i = i + 1
			j = i
			output_trio = (2, new_i, j)
			output.append(output_trio)
		elif all_nums[i] == max_key:
			continue
	for i in range(max_position - 1, -1, -1):
		if all_nums[i] < max_key:
			new_i = i + 1
			j = i + 2
			output_trio = (1, new_i, j)
			output.append(output_trio)
		elif all_nums[i] > max_key:
			new_i = i + 1
			j = i + 2
			output_trio = (2, new_i, j)
			output.append(output_trio)
		elif all_nums[i] == max_key:
			continue
	return (len(output), output)

def print_output(output_tuple):
	a = output_tuple[0]
	matrix = output_tuple[1]
	print(a)
	for i in matrix:
		new_i = str(i)
		new_i = new_i.replace(',', '')
		new_i = new_i.strip('(')
		new_i = new_i.strip(')')
		print(new_i)
max_key_max_position = find_max(all_nums)
output_tuple = change_rest_elements(all_nums, max_key_max_position)
print_output(output_tuple)


import collections as cc
n = int(input())
l = list(map(int, input().split()))
count = 0
fr = cc.Counter(l)
fr = fr.most_common(1)[0][0]
index = l.index(fr)
ans = []
for i in range(index - 1, -1, -1):
	if l[i] < fr:
		count += 1
		ans.append([1, i + 1, i + 2])
	if l[i] > fr:
		count += 1
		ans.append([2, i + 1, i + 2])
for i in range(index + 1, n):
	if l[i] < fr:
		count += 1
		ans.append([1, i + 1, i])
	if l[i] > fr:
		count += 1
		ans.append([2, i + 1, i])
print(count)
for i in ans:
	print(*i)


from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
res = []
wefind = Counter(a).most_common(1)[0][0]
firstindex = a.index(wefind)
i = firstindex - 1
while i >= 0:
	if a[i] < wefind:
		res.append((1, i, i + 1))
	elif a[i] > wefind:
		res.append((2, i, i + 1))
	i -= 1
i = firstindex + 1
while i < len(a):
	if a[i] < wefind:
		res.append((1, i, i - 1))
	elif a[i] > wefind:
		res.append((2, i, i - 1))
	i += 1
print(len(res))
for i in res:
	print(i[0], i[1] + 1, i[2] + 1)


import atexit
import io
import sys
_I_B = sys.stdin.read().splitlines()
input = iter(_I_B).__next__
_O_B = io.StringIO()
sys.stdout = _O_B

@atexit.register
def write():
	sys.__stdout__.write(_O_B.getvalue())
n = int(input())
a = list(map(int, input().split()))
d = dict()
for i in a:
	try:
		d[i] += 1
	except KeyError:
		d[i] = 1
m = -1
ii = -1
for i in d:
	if d[i] > m:
		m = d[i]
		ii = i
print(n - m)
ti = a.index(ii)
for i in range(ti + 1, n):
	if a[i] < ii:
		print(1, i + 1, i)
	elif a[i] > ii:
		print(2, i + 1, i)
for i in range(ti - 1, -1, -1):
	if a[i] < ii:
		print(1, i + 1, i + 2)
	elif a[i] > ii:
		print(2, i + 1, i + 2)


n = int(input())
a = list(map(int, input().split()))
d = dict()
for i in range(0, 200005):
	d[i] = 0
for i in range(n):
	d[a[i]] += 1
maxa = num = 0
for i in range(200005):
	if num < d[i]:
		maxa = i
		num = d[i]
ans = n - num
print(ans)
if ans == 0:
	exit()
for i in range(n - 1):
	if a[i] == maxa:
		continue
	if i == 0:
		if a[i + 1] == maxa:
			if a[i] < maxa:
				print(1, i + 1, i + 2)
			else:
				print(2, i + 1, i + 2)
			a[i] = maxa
		continue
	if a[i + 1] == maxa:
		if a[i] < maxa:
			print(1, i + 1, i + 2)
		else:
			print(2, i + 1, i + 2)
		a[i] = maxa
		continue
	if a[i - 1] == maxa:
		if a[i] < maxa:
			print(1, i + 1, i)
		else:
			print(2, i + 1, i)
		a[i] = maxa
		continue
if a[n - 1] != maxa:
	if a[n - 1] < maxa:
		print(1, n, n - 1)
	else:
		print(2, n, n - 1)
	a[n - 1] = maxa
for i in range(n - 1, -1, -1):
	if a[i] != maxa:
		if a[i] < maxa:
			print(1, i + 1, i + 2)
		else:
			print(2, i + 1, i + 2)


n = int(input(''))
a = input('').split()
count = [0 for _ in range(200001)]
max_count = -1
max_number = -1
max_index = -1
for i in range(n):
	a[i] = int(a[i])
	count[a[i]] += 1
	if count[a[i]] > max_count:
		max_count = count[a[i]]
		max_number = a[i]
		max_index = i
tot = n - max_count
print(tot)
curr = max_index - 1
while curr >= 0:
	if a[curr] > max_number:
		print('2 ' + str(curr + 1) + ' ' + str(curr + 2))
	elif a[curr] < max_number:
		print('1 ' + str(curr + 1) + ' ' + str(curr + 2))
	curr -= 1
curr = max_index + 1
while curr < n:
	if a[curr] > max_number:
		print('2 ' + str(curr + 1) + ' ' + str(curr))
	elif a[curr] < max_number:
		print('1 ' + str(curr + 1) + ' ' + str(curr))
	curr += 1


a = int(input())
s = [int(x) for x in input().split()]
d = {}
n = 0
for i in range(a):
	d[s[i]] = 0
for i in s:
	d[i] += 1
x = 0
it = 0
for i in d:
	if d[i] > it:
		x = i
		it = d[i]
c = s.index(x)
for i in s:
	if i != x:
		n += 1
print(n)
for i in range(c - 1, -1, -1):
	if s[i] < x:
		print(f'1 {i + 1} {i + 2}')
	elif s[i] > x:
		print(f'2 {i + 1} {i + 2}')
for i in range(c + 1, a):
	if s[i] < x:
		print(f'1 {i + 1} {i}')
	elif s[i] > x:
		print(f'2 {i + 1} {i}')


import sys
from collections import defaultdict
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
ans = []
(num, cur) = (0, 0)
dic = defaultdict(int)
for i in range(n):
	dic[arr[i]] += 1
	if dic[arr[i]] > cur:
		cur = dic[arr[i]]
		num = arr[i]
ind = -1
for i in range(n):
	if arr[i] == num:
		ind = i
		break
ans = []
for i in range(ind):
	if arr[i] > num:
		ans.append([2, i + 1, i + 2])
	elif arr[i] < num:
		ans.append([1, i + 1, i + 2])
ans.reverse()
for i in range(ind + 1, n):
	if arr[i] > num:
		ans.append([2, i + 1, i])
	elif arr[i] < num:
		ans.append([1, i + 1, i])
print(len(ans))
for i in range(len(ans)):
	print(*ans[i])


R = lambda : map(int, input().split())
n = int(input())
L = list(R())
f = [0] * (max(L) + 1)
for i in L:
	f[i] += 1
ma = max(f)
ind = f.index(ma)
A = [0] * n
for i in range(n):
	if L[i] == ind:
		A[i] = 1
res = n - ma
print(res)
j = L.index(ind)
while j >= 0:
	if A[j] == 0:
		A[j] = 1
		if L[j] > ind:
			print(2, j + 1, j + 2)
		else:
			print(1, j + 1, j + 2)
	j -= 1
j = L.index(ind)
while j < n:
	if A[j] == 0:
		A[j] = 1
		if L[j] > ind:
			print(2, j + 1, j)
		else:
			print(1, j + 1, j)
	j += 1


n = int(input())
nums = list(map(int, input().split()))
count = dict()
for i in range(n):
	if nums[i] in count.keys():
		count[nums[i]][0] += 1
		count[nums[i]].append(i)
	else:
		count[nums[i]] = [1]
		count[nums[i]].append(i)
currCount = 1
currElem = nums[0]
currInd = [0]
for key in count.keys():
	if count[key][0] > currCount:
		currCount = count[key][0]
		currElem = key
		currInd = count[key][1:]
currInd.sort()
steps = n - len(currInd)
print(steps)
if currInd[0] != 0:
	for i in range(currInd[0] - 1, -1, -1):
		if nums[i] > currElem:
			print(2, i + 1, i + 2)
		elif nums[i] < currElem:
			print(1, i + 1, i + 2)
for i in range(len(currInd)):
	if i == len(currInd) - 1:
		if currInd[i] < n - 1:
			for j in range(currInd[i] + 1, n):
				if nums[j] > currElem:
					print(2, j + 1, j)
				elif nums[j] < currElem:
					print(1, j + 1, j)
	else:
		left = currInd[i]
		right = currInd[i + 1]
		for j in range(left + 1, right):
			if nums[j] > currElem:
				print(2, j + 1, j)
			elif nums[j] < currElem:
				print(1, j + 1, j)


n = int(input())
v = [int(x) for x in input().split()]
hist = {}
for x in v:
	hist.setdefault(x, 0)
	hist[x] += 1
target = max(hist, key=lambda x: hist[x])
print(len(v) - hist[target])
start = v.index(target)
for i in range(start, len(v)):
	if v[i] == target:
		continue
	if v[i] < target:
		op = 1
	else:
		op = 2
	v[i] = target
	print('{} {} {}'.format(op, i + 1, i))
for i in range(start, -1, -1):
	if v[i] == target:
		continue
	if v[i] < target:
		op = 1
	else:
		op = 2
	v[i] = target
	print('{} {} {}'.format(op, i + 1, i + 2))


def mostFrequent(arr, n):
	Hash = dict()
	for i in range(n):
		if arr[i] in Hash.keys():
			Hash[arr[i]] += 1
		else:
			Hash[arr[i]] = 1
	max_count = 0
	res = -1
	for i in Hash:
		if max_count < Hash[i]:
			res = i
			max_count = Hash[i]
	return res
from sys import stdin
input = stdin.readline
n = int(input())
l = list(map(int, input().split()))
s = set(l)
x = mostFrequent(l, n)
a = []
ind = l.index(x)
for i in range(0, ind):
	if l[ind - i - 1] < x:
		a.append([1, ind - i, ind - i + 1])
	elif l[ind - i - 1] > x:
		a.append([2, ind - i, ind - i + 1])
for i in range(ind + 1, n):
	if l[i] < x:
		a.append([1, i + 1, i])
	elif l[i] > x:
		a.append([2, i + 1, i])
print(len(a))
for i in a:
	print(*i)


from sys import stdin, stdout
stdin.readline

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

def it():
	return int(stdin.readline().strip())
from collections import defaultdict as dd, Counter as C, deque
from math import ceil, gcd, sqrt, factorial, log2, floor
n = it()
l = mp()
c = C(l)
ma = max(c.values())
for (i, j) in c.items():
	if ma == j:
		key = i
		break
v = []
ind = l.index(key)
for i in range(ind + 1, n):
	if i != n - 1:
		if l[i] < key:
			v.append([1, i + 1, i])
		elif l[i] > key:
			v.append([2, i + 1, i])
	elif l[i] < key:
		v.append([1, i + 1, i])
	elif l[i] > key:
		v.append([2, i + 1, i])
for i in range(ind - 1, -1, -1):
	if i != 0:
		if l[i] < key:
			v.append([1, i + 1, i + 2])
		elif l[i] > key:
			v.append([2, i + 1, i + 2])
	elif l[i] < key:
		v.append([1, i + 1, i + 2])
	elif l[i] > key:
		v.append([2, i + 1, i + 2])
print(len(v))
for i in v:
	print(*i)


from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
(val, maxCnt) = Counter(arr).most_common(1)[0]
x = arr.index(val)
print(n - maxCnt)
for i in range(x - 1, -1, -1):
	if arr[i] != val:
		print(1 if val > arr[i] else 2, i + 1, i + 2)
for i in range(x + 1, len(arr)):
	if arr[i] != val:
		print(1 if val > arr[i] else 2, i + 1, i)


from copy import copy
from itertools import groupby
n = int(input())
array = list(map(int, input().strip().split(' ')))
s = copy(array)
s.sort()
res = max(groupby(s), key=lambda item: len(list(item[1])))
target_value = res[0]
ready = list(filter(lambda x: x[1] == target_value, enumerate(array)))
first_ready = ready[0][0]
steps = len(array) - len(ready)
print(steps)
if first_ready > 0:
	for i in range(first_ready - 1, -1, -1):
		if array[i] < target_value:
			print(1, i + 1, i + 2)
		else:
			print(2, i + 1, i + 2)
for i in range(first_ready + 1, len(array)):
	if array[i] == target_value:
		pass
	elif array[i] < target_value:
		print(1, i + 1, i)
	else:
		print(2, i + 1, i)


n = int(input())
arr = [int(x) for x in input().split()]
cnt = {}
for x in arr:
	if x in cnt:
		cnt[x] += 1
	else:
		cnt[x] = 1
(mx_num, mx_cnt) = max(cnt.items(), key=lambda x: x[1])
first_index = 0
for (i, x) in enumerate(arr):
	if mx_num == x:
		first_index = i
		break
print(n - mx_cnt)
for i in range(first_index - 1, -1, -1):
	j = i + 1
	if mx_num == arr[i]:
		continue
	if mx_num > arr[i]:
		t = 1
	else:
		t = 2
	print(t, i + 1, j + 1)
for i in range(first_index + 1, n):
	j = i - 1
	if mx_num == arr[i]:
		continue
	if mx_num > arr[i]:
		t = 1
	else:
		t = 2
	print(t, i + 1, j + 1)


import collections
n = int(input())
mini = 2 * 10 ** 5
maxi = 0
a = [int(x) for x in input().split()]
d = collections.defaultdict(int)
for x in a:
	d[x] += 1
cnt = 0
for k in d.keys():
	if d[k] > cnt:
		cnt = d[k]
		num = k
for i in range(n):
	if a[i] == num:
		index = i
		break
ans = []
for i in range(index + 1, n):
	if a[i] > num:
		ans.append('2 ' + str(i + 1) + ' ' + str(i))
	elif a[i] < num:
		ans.append('1 ' + str(i + 1) + ' ' + str(i))
for i in range(index - 1, -1, -1):
	if a[i] > num:
		ans.append('2 ' + str(i + 1) + ' ' + str(i + 2))
	elif a[i] < num:
		ans.append('1 ' + str(i + 1) + ' ' + str(i + 2))
print(len(ans))
for x in ans:
	print(x)


n = int(input())
Arr = list(map(int, input().split(' ')))
dicti = {}
for i in Arr:
	if i in dicti:
		dicti[i] += 1
	else:
		dicti[i] = 1
maxi = 0
maxchar = 0
for i in dicti:
	if dicti[i] > maxi:
		maxi = dicti[i]
		maxchar = i
index = Arr.index(maxchar)
print(n - maxi)
tempInd = index
for i in range(tempInd + 1, n):
	if Arr[i] == maxchar:
		continue
	elif Arr[i] > maxchar:
		print(2, i + 1, i)
	else:
		print(1, i + 1, i)
for i in range(tempInd, -1, -1):
	if Arr[i] == maxchar:
		continue
	elif Arr[i] > maxchar:
		print(2, i + 1, i + 2)
	else:
		print(1, i + 1, i + 2)


n = int(input())
a = list(map(int, input().split()))
ints = [0] * (2 * 10 ** 5 + 1)
max_ = 0
argmax = 0
for i in a:
	ints[i] += 1
	if ints[i] > max_:
		max_ = ints[i]
		argmax = i
print(n - ints[argmax])
flag = True
for (i, value) in enumerate(a):
	if value == argmax and flag:
		flag = False
		j = i - 1
		while j >= 0 and a[j] != argmax:
			if a[j] < argmax:
				print(1, j + 1, j + 2)
			else:
				print(2, j + 1, j + 2)
			j -= 1
	if not flag:
		if value != argmax:
			if a[i] < argmax:
				print(1, i + 1, i)
			else:
				print(2, i + 1, i)


num = int(input().strip())
numbers = [int(i) for i in input().strip().split()]
num_dict = dict()
for i in numbers:
	if i not in num_dict:
		num_dict[i] = 1
	else:
		num_dict[i] += 1
max_number = 0
max_index = 0
for i in num_dict:
	if num_dict[i] > max_number:
		max_index = i
		max_number = num_dict[i]
for i in range(num):
	if numbers[i] == max_index:
		index = i
		break
left = index - 1
right = index + 1
ans = []
while left >= 0 or right < num:
	if left >= 0:
		if numbers[left] != max_index:
			if numbers[left] < max_index:
				ans.append((1, left + 1, left + 1 + 1))
			else:
				ans.append((2, left + 1, left + 1 + 1))
		left -= 1
	if right < num:
		if numbers[right] != max_index:
			if numbers[right] < max_index:
				ans.append((1, right + 1, right - 1 + 1))
			else:
				ans.append((2, right + 1, right - 1 + 1))
		right += 1
print(len(ans))
for i in ans:
	print(' '.join((str(j) for j in i)))


import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
cnt = [0] * 200005
M = 0
key = 0
for i in a:
	cnt[i] += 1
	if key < cnt[i]:
		M = i
		key = cnt[i]
print(N - key)
stack = []
idx = 0
for i in a:
	if i != M:
		stack.append(i)
	else:
		break
	idx += 1
save = idx
while stack:
	print(2 if stack.pop() > M else 1, idx, idx + 1)
	idx -= 1
for i in range(save, N):
	if a[i] != M:
		print(2 if a[i] > M else 1, i + 1, i)


import math
from collections import defaultdict, deque

def balance(arr):
	ops = deque([])
	frequencies = defaultdict(int)
	for x in arr:
		frequencies[x] += 1
	most_common = None
	max_fr = -1
	for (x, fr) in frequencies.items():
		if fr > max_fr:
			most_common = x
			max_fr = fr
	i = arr.index(most_common)
	for j in range(i - 1, -1, -1):
		if arr[j] < most_common:
			ops.append((1, j + 1, j + 2))
		else:
			ops.append((2, j + 1, j + 2))
	i += 1
	while i < len(arr):
		if arr[i] < most_common:
			ops.append((1, i + 1, i))
		elif arr[i] > most_common:
			ops.append((2, i + 1, i))
		i += 1
	print(len(ops))
	for op in ops:
		print(' '.join(map(str, op)))
n = int(input())
arr = list(map(int, input().split()))
balance(arr)


n = int(input())
A = list(map(int, input().split()))
cnt = {}
for i in A:
	if i not in cnt:
		cnt[i] = 0
	cnt[i] += 1
mas = 0
z = 0
for u in cnt:
	if mas < cnt[u]:
		mas = cnt[u]
		z = u
print(len(A) - cnt[z])
zind = A.index(z)
for u in range(zind - 1, -1, -1):
	if A[u] < z:
		print(1, u + 1, u + 2)
	elif A[u] > z:
		print(2, 1 + u, u + 2)
for i in range(zind, n):
	if A[i] < z:
		print(1, i + 1, i)
	elif A[i] > z:
		print(2, i + 1, i)


n = int(input())
a = list(map(int, input().split()))
b = dict()
b[a[0]] = 0
maxim = a[0]
for i in a:
	if i in b:
		b[i] += 1
		if b[i] > b[maxim]:
			maxim = i
	else:
		b[i] = 1
maxindex = [0]
j = 0
if a[0] != maxim:
	j = 1
for i in range(1, len(a)):
	if a[i] == maxim:
		maxindex.append(i)
print(n - len(maxindex) + j)
for i in range(len(maxindex) - 1):
	j1 = maxindex[i]
	j2 = maxindex[i + 1]
	while j2 != j1:
		if a[j2] - a[j2 - 1] > 0:
			print(1, j2 - 1 + 1, j2 + 1)
			a[j2 - 1] += abs(a[j2 - 1] - a[j2])
		elif a[j2 - 1] - a[j2] > 0:
			print(2, j2 - 1 + 1, j2 + 1)
			a[j2 - 1] -= abs(a[j2 - 1] - a[j2])
		j2 -= 1
j1 = maxindex[-1]
for i in range(j1, len(a) - 1):
	if a[i] - a[i + 1] > 0:
		print(1, i + 2, i + 1)
		a[i + 1] += abs(a[i + 1] - a[i])
	else:
		print(2, i + 2, i + 1)
		a[i + 1] -= abs(a[i] - a[i + 1])


import sys
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
n = int(input())
l = list(map(int, input().split()))
p = -1
m = 0
x = dc(int)
y = -1
for i in range(n):
	x[l[i]] += 1
	if x[l[i]] > m:
		m = x[l[i]]
		p = l[i]
		y = i
print(n - m)
if n - m > 0:
	for i in range(y - 1, -1, -1):
		if l[i] != p:
			if l[i + 1] > l[i]:
				l[i] = p
				print(1, i + 1, i + 2)
			else:
				l[i] = p
				print(2, i + 1, i + 2)
	for i in range(y + 1, n):
		if l[i] != p:
			if l[i - 1] > l[i]:
				l[i] = p
				print(1, i + 1, i)
			else:
				l[i] = p
				print(2, i + 1, i)


n = int(input())
arr = list(map(int, input().split()))
d = {}
for i in arr:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
mm = 0
xx = 0
for (key, value) in d.items():
	if value > mm:
		xx = key
		mm = value
if mm == 1:
	xx = min(arr)
pos = []
for i in range(len(arr)):
	if arr[i] == xx:
		pos.append(i)
ans = []
pre = -1
for i in pos:
	if pre == -1:
		for j in range(i, 0, -1):
			if arr[j] > arr[j - 1]:
				ans.append([1, j, j + 1])
				arr[j - 1] = arr[j]
			elif arr[j - 1] > arr[j]:
				ans.append([2, j, j + 1])
				arr[j - 1] = arr[j]
	else:
		for j in range(i, pre, -1):
			if arr[j] > arr[j - 1]:
				ans.append([1, j, j + 1])
				arr[j - 1] = arr[j]
			elif arr[j - 1] > arr[j]:
				ans.append([2, j, j + 1])
				arr[j - 1] = arr[j]
	pre = i
for i in range(pre, len(arr) - 1, 1):
	if arr[i] < arr[i + 1]:
		ans.append([2, i + 2, i + 1])
		arr[i + 1] = arr[i]
	elif arr[i + 1] < arr[i]:
		ans.append([1, i + 2, i + 1])
		arr[i + 1] = arr[i]
print(len(ans))
for i in range(len(ans)):
	print(ans[i][0], ans[i][1], ans[i][2])


import sys
from collections import Counter, deque

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

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

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
N = INT()
A = LIST()
C = Counter(A)
C = C.most_common()
base = C[0][0]
bases = []
for i in range(N):
	if A[i] == base:
		bases.append(i)
ans = []
for i in range(len(bases)):
	for j in range(bases[i] - 1, -1, -1):
		if A[j] == base:
			break
		else:
			if A[j] < base:
				ans.append((1, j + 1, j + 2))
			else:
				ans.append((2, j + 1, j + 2))
			A[j] = base
	for j in range(bases[i] + 1, N):
		if A[j] == base:
			break
		else:
			if A[j] < base:
				ans.append((1, j + 1, j))
			else:
				ans.append((2, j + 1, j))
			A[j] = base
print(len(ans))
for (t, i, j) in ans:
	print(t, i, j)


n = int(input())
l = [*map(int, input().split())]
cnt = [0] * 200001
for i in l:
	cnt[i] += 1
mx = num = -1
for i in range(200001):
	if mx < cnt[i]:
		mx = cnt[i]
		num = i
idx = -1
for i in range(n):
	if num == l[i]:
		idx = i
		break
res = []
for i in range(idx - 1, -1, -1):
	if l[i] < l[i + 1]:
		res.append([1, i, i + 1])
	elif l[i] > l[i + 1]:
		res.append([2, i, i + 1])
	l[i] = l[i + 1]
for i in range(idx + 1, n):
	if l[i] < l[i - 1]:
		res.append([1, i, i - 1])
	elif l[i] > l[i - 1]:
		res.append([2, i, i - 1])
	l[i] = l[i - 1]
print(len(res))
for i in res:
	print(i[0], i[1] + 1, i[2] + 1)


import sys, bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

def Golf():
	(n, *t) = map(int, open(0).read().split())

def I():
	return int(input())

def S_():
	return input()

def IS():
	return input().split()

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

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

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

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RA():
	return map(int, open(0).read().split())

def RLI(n=8, a=1, b=10):
	return [random.randint(a, b) for i in range(n)]

def RI(a=1, b=10):
	return random.randint(a, b)

def Rtest(T):
	(case, err) = (0, 0)
	for i in range(T):
		inp = INP()
		(a1, ls) = naive(*inp)
		a2 = solve(*inp)
		if a1 != a2:
			print((a1, a2), inp)
			err += 1
		case += 1
	print('Tested', case, 'case with', err, 'errors')

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
l_alp = string.ascii_lowercase
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()
show_flg = False
show_flg = True
ans = 0
ans = []
(n, *a) = map(int, open(0).read().split())
c = sorted(Counter(a).items(), key=lambda x: x[1])
x = c[-1][0]
q = []
for i in range(n):
	if a[i] == x:
		q += (i,)
while q:
	u = q.pop()
	for v in [u - 1, u + 1]:
		if 0 <= v < n and a[v] != x:
			q += (v,)
			if a[v] < x:
				t = 1
			else:
				t = 2
			ans += [(t, v + 1, u + 1)]
			a[v] = x
print(len(ans))
for i in ans:
	print(*i)


n = int(input())
a = list(map(int, input().split()))
c = [0] * 200001
for i in range(n):
	c[a[i]] += 1
x = -1
ma = 0
for i in range(200001):
	if c[i] > ma:
		ma = c[i]
		x = i
l = []
print(n - ma)
for i in range(n):
	if a[i] == x:
		l.append(i)
j = l[0]
while j > 0:
	if a[j - 1] > a[j]:
		print(2, j, j + 1)
	else:
		print(1, j, j + 1)
	a[j - 1] = x
	j -= 1
for i in range(len(l) - 1):
	j = l[i]
	while j < l[i + 1] - 1:
		if a[j + 1] > a[j]:
			print(2, j + 2, j + 1)
		else:
			print(1, j + 2, j + 1)
		a[j + 1] = x
		j += 1
j = l[len(l) - 1]
while j < n - 1:
	if a[j + 1] > a[j]:
		print(2, j + 2, j + 1)
	else:
		print(1, j + 2, j + 1)
	a[j + 1] = x
	j += 1


n = int(input())
a = list(map(int, input().split(' ')))
cnt = {}
ans = 0
val = 0
for i in range(0, n):
	try:
		cnt[a[i]] += 1
		if ans < cnt[a[i]]:
			ans = cnt[a[i]]
			pos = i
			val = a[i]
	except:
		cnt[a[i]] = 1
		if ans < cnt[a[i]]:
			ans = cnt[a[i]]
			pos = i
			val = a[i]
print(n - ans)
for i in range(pos - 1, -1, -1):
	if a[i] < a[i + 1]:
		print('1 ' + str(i + 1) + ' ' + str(i + 2))
		a[i] = val
	elif a[i] > a[i + 1]:
		print('2 ' + str(i + 1) + ' ' + str(i + 2))
		a[i] = val
for i in range(pos + 1, n):
	if a[i] < a[i - 1]:
		print('1 ' + str(i + 1) + ' ' + str(i))
		a[i] = val
	elif a[i] > a[i - 1]:
		print('2 ' + str(i + 1) + ' ' + str(i))
		a[i] = val


from collections import Counter
n = int(input())
arr = [int(p) for p in input().split()]
cntr = Counter(arr)
m = max(cntr.values())
for i in cntr:
	if cntr[i] == m:
		val = i
print(n - m)
i = arr.index(val)
for j in range(i - 1, -1, -1):
	if arr[j] < val:
		arr[j] = val
		print(1, j + 1, j + 2)
	else:
		arr[j] = val
		print(2, j + 1, j + 2)
for j in range(n):
	if arr[j] < val:
		arr[j] = val
		print(1, j + 1, j)
	elif arr[j] > val:
		arr[j] = val
		print(2, j + 1, j)


def check(line):
	lst = sorted(line, key=lambda s: int(s))
	for i in range(2, len(lst)):
		if lst[i] == lst[i - 2]:
			return False
	return lst

def main():
	n_row = input()
	line = input()
	num = line.strip(' ').split(' ')
	num = [int(i) for i in num]
	dic = {}
	for i in num:
		if i in dic.keys():
			dic[i] += 1
		else:
			dic[i] = 1
	(key, cnt) = (0, 0)
	for (i, j) in dic.items():
		if j > cnt:
			(key, cnt) = (i, j)
	idx = 0
	for (i, j) in enumerate(num):
		if j == key:
			idx = i
			break
	i = idx - 1
	answer = []
	while i >= 0:
		if num[i] != key:
			if num[i] < key:
				answer.append((1, i + 1, i + 2))
			elif num[i] > key:
				answer.append((2, i + 1, i + 2))
		i -= 1
	i = idx + 1
	while i < len(num):
		if num[i] < key:
			answer.append((1, i + 1, i))
		elif num[i] > key:
			answer.append((2, i + 1, i))
		i += 1
	print(len(answer))
	for item in answer:
		print(item[0], item[1], item[2])
main()


from typing import List, Tuple
import sys
DEBUG = len(sys.argv) > 1 and sys.argv[1] == '-d'

def LOG(*argv):
	if DEBUG:
		print(*argv, file=sys.stderr)

def CHECK(cond, err_msg=''):
	if DEBUG:
		assert cond, err_msg

def CHECK_EQ(a, b, err_msg=''):
	CHECK(a == b, err_msg='{} v.s. {} {}'.format(a, b, err_msg))

def readval(typ=int):
	return typ(input())

def readvals(typ=int):
	return list(map(typ, input().split()))

def solve(arr: List[int]) -> None:
	n = len(arr)
	solution = []

	def make_equal(i, j):
		diff = arr[j] - arr[i]
		if diff > 0:
			solution.append(f'1 {i + 1} {j + 1}')
		elif diff < 0:
			solution.append(f'2 {i + 1} {j + 1}')
		arr[i] = arr[j]

	def move_fwd(idx, target_v):
		assert arr[idx] == target_v
		while idx + 1 < n:
			make_equal(i=idx + 1, j=idx)
			idx += 1

	def move_bck(idx, target_v):
		assert arr[idx] == target_v
		while idx - 1 >= 0:
			make_equal(i=idx - 1, j=idx)
			idx -= 1
	from collections import Counter
	ctr = Counter(arr)
	target_v = ctr.most_common(1)[0][0]
	start_idx = arr.index(target_v)
	move_fwd(start_idx, target_v)
	move_bck(start_idx, target_v)
	print(len(solution))
	for line in solution:
		print(line)
n = readval()
arr = readvals()
solve(arr)


m = int(input())
a = list(map(int, input().split()))
c = [0 for i in range(200000 + 1)]
inc = []
dec = []
mark = []
l = 0
i = 0
l1 = 0
max = 0
check = 0
maxi = 0
mark1 = []
r = 0
while i < len(a):
	c[a[i]] += 1
	i += 1
i = 0
while i < len(c):
	if c[i] > max:
		max = c[i]
		maxi = i
	i += 1
i = 0
while i < len(a):
	if check == 0:
		if a[i] < maxi:
			mark.append(str(1) + ' ' + str(i + 1) + ' ' + str(i + 2))
			r += 1
		elif a[i] > maxi:
			r += 1
			mark.append(str(2) + ' ' + str(i + 1) + ' ' + str(i + 2))
		elif a[i] == maxi or a[i + 1] == maxi:
			check = 1
	elif a[i] > maxi:
		r += 1
		mark1.append(str(2) + ' ' + str(i + 1) + ' ' + str(i))
	elif a[i] < maxi:
		r += 1
		mark1.append(str(1) + ' ' + str(i + 1) + ' ' + str(i))
	i += 1
print(r)
for i in range(len(mark) - 1, -1, -1):
	print(mark[i])
for i in range(len(mark1)):
	print(mark1[i])


x = int(input())
y = list(map(int, input().split(' ')))
s = [0] * 10 ** 6
for i in y:
	s[i] += 1
m = 0
z = 0
for i in range(len(s)):
	if s[i] > m:
		m = s[i]
		z = i
q = 0
print(len(y) - m)
for i in range(len(y)):
	if y[i] == z:
		for j in range(i - 1, q - 1, -1):
			if y[j] > z:
				print(2, j + 1, j + 2)
			else:
				print(1, j + 1, j + 2)
		q = i + 1
for j in range(q, len(y)):
	if y[j] > z:
		print(2, j + 1, j)
	else:
		print(1, j + 1, j)


n = int(input())
a = [int(i) for i in input().split()]
maxi1 = a[0]
d = dict(((i, 0) for i in a))
for i in range(n):
	d[a[i]] += 1
	if d[a[i]] > d[maxi1]:
		maxi1 = a[i]
for i in range(n):
	if a[i] == maxi1:
		maxi = i
s = ''
c = 0
for i in range(maxi - 1, -1, -1):
	if a[i] < a[maxi]:
		c += 1
		s += '1 ' + str(i + 1) + ' ' + str(i + 2) + '\n'
	elif a[i] > a[maxi]:
		c += 1
		s += '2 ' + str(i + 1) + ' ' + str(i + 2) + '\n'
for i in range(maxi + 1, n):
	if a[i] < a[maxi]:
		c += 1
		s += '1 ' + str(i + 1) + ' ' + str(i) + '\n'
	elif a[i] > a[maxi]:
		c += 1
		s += '2 ' + str(i + 1) + ' ' + str(i) + '\n'
print(c)
print(s[:-1])


def run(n, a):
	dic = {}
	co = 0
	maxx = -1
	index = -1
	for i in range(n):
		dic[a[i]] = dic.get(a[i], 0) + 1
		if dic[a[i]] > co:
			co = dic[a[i]]
			maxx = a[i]
			index = i
	temp = 0
	for i in a:
		if i == maxx:
			temp += 1
	print(n - temp)
	for i in range(index + 1, n):
		if maxx > a[i]:
			print('1 ' + str(i + 1) + ' ' + str(i))
		if a[i] > maxx:
			print('2 ' + str(i + 1) + ' ' + str(i))
	for i in range(index - 1, -1, -1):
		if maxx > a[i]:
			print('1 ' + str(i + 1) + ' ' + str(i + 2))
		if a[i] > maxx:
			print('2 ' + str(i + 1) + ' ' + str(i + 2))
n = int(input())
a = list(map(int, input().split()))
run(n, a)


n = int(input())
a = list(map(int, input().split()))
maxi = 0
el = -1
d = dict()
for i in a:
	if i in d:
		d[i] += 1
		if d[i] > maxi:
			maxi = d[i]
			el = i
	else:
		d[i] = 1
		if d[i] > maxi:
			maxi = d[i]
			el = i
print(n - maxi)
for i in range(a.index(el) - 1, -1, -1):
	print(1 + int(a[i] > el), i + 1, i + 2)
for i in range(a.index(el) + 1, n):
	if a[i] == el:
		continue
	print(1 + int(a[i] > el), i + 1, i)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, 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()
	c = collections.Counter(a)
	m = max(c.values())
	t = 0
	for (k, v) in c.items():
		if v == m:
			t = k
			break
	r = []
	for i in range(n):
		if a[i] == t:
			for j in range(i - 1, -1, -1):
				if a[j] == t:
					break
				if a[j] < t:
					r.append('1 {} {}'.format(j + 1, j + 2))
				else:
					r.append('2 {} {}'.format(j + 1, j + 2))
				a[j] = t
			for j in range(i + 1, n):
				if a[j] == t:
					break
				if a[j] < t:
					r.append('1 {} {}'.format(j + 1, j))
				else:
					r.append('2 {} {}'.format(j + 1, j))
				a[j] = t
	return '{}\n{}'.format(len(r), '\n'.join(r))
print(main())


import collections

def CountFrequency(arr):
	return collections.Counter(arr)
n = int(input())
a = list(map(int, input().split()))
freq = CountFrequency(a)
x = max(freq.items(), key=lambda x: x[1])[0]
if freq[x] != 1:
	print(abs(freq[x] - len(a)))
	for i in range(n - 1, -1, -1):
		if a[i] == x:
			break
	w = i
	for i in range(w - 1, -1, -1):
		if a[i] != x and a[i] < x:
			print('1', i + 1, i + 2)
		if a[i] != x and a[i] > x:
			print('2', i + 1, i + 2)
	for i in range(w + 1, n):
		if a[i] != x and a[i] < x:
			print('1', i + 1, i)
		if a[i] != x and a[i] > x:
			print('2', i + 1, i)
else:
	print(abs(freq[x] - len(a)))
	x = a[n - 1]
	for i in range(n - 2, -1, -1):
		if a[i] != x and a[i] < x:
			print('1', i + 1, i + 2)
		if a[i] != x and a[i] > x:
			print('2', i + 1, i + 2)


n = int(input())
a = list(map(int, input().split()))
from collections import Counter

def compute_mode(numbers):
	counts = Counter(numbers)
	maxcount = max(counts.values())
	for (num, count) in counts.items():
		if count == maxcount:
			return num
m = compute_mode(a)
mi = a.index(m)
k = []
for i in range(mi - 1, -1, -1):
	if a[i] > m:
		k.append([2, i + 1, i + 2])
	elif a[i] < m:
		k.append([1, i + 1, i + 2])
for i in range(mi + 1, n):
	if a[i] > m:
		k.append([2, i + 1, i])
	elif a[i] < m:
		k.append([1, i + 1, i])
print(len(k))
for i in k:
	print(*i)