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

Difficulty: introductory

Starter code:

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

#Bhargey Mehta (Sophomore)
#DA-IICT, Gandhinagar
import sys, math, queue
sys.setrecursionlimit(1000000)
#sys.stdin = open("input.txt", "r")

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)

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)



''' CODED WITH LOVE BY SATYAM KUMAR '''

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) # max depth of recursion
threading.stack_size(2**27)  # new thread will get stack of such size
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): #n**0.5 complex 
    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
    #print (n,MOD)
    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):
    """Returns True if n is prime."""
    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 = []                         # list of entries arranged in a heap
entry_finder = {}               # mapping of tasks to entries
REMOVED = '<removed-task>' 
def add_task(task, priority=0):
    'Add a new task or update the priority of an existing task'
    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):
    'Mark an existing task as REMOVED.  Raise KeyError if not found.'
    entry = entry_finder.pop(task)
    entry[-1] = REMOVED

def pop_task():
    'Remove and return the lowest priority task. Raise KeyError if empty.'
    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):
    #print("Search for ",i)
    fn = lambda x: li[x]-x//i
    x = -1
    b = len(li)
    while b>=1:
        #print(b,x)
        while b+x<len(li) and fn(b+x)>0: #Change this condition 2 to whatever you like
            x+=b
        b=b//2
    return x

# -------------------------------------------------------------- MAIN PROGRAM
TestCases = False
testingMode = False
fac_warmup_size = 10**5+100
optimiseForReccursion = True #Can not be used clubbed with TestCases # WHen using recursive functions, use Python 3
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)

    
# --------------------------------------------------------------------- END=


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

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


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)


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
        


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)


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)

# -*- coding: utf-8 -*-

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

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)

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

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

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)


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)


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)


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
# python template for atcoder1
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())
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)


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)

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)


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)