#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve() {
   int n;
   cin >> n;
   int a[n];
   int f[200005] = {0};
    for(int i=0;i<n;i++) {
        cin >> a[i];
        f[a[i]]++;
    }
    int mx = 0;
    for(int i=0;i<n;i++) {
        if(f[a[i]]) {
            if(f[a[i]] > f[mx])
                mx = a[i];
        }
    }
    int pos;
    for(int i=0;i<n;i++) {
        if(a[i] == mx) {
            pos = i;
            break;
        }
    }
    cout << n - f[mx] << endl;
    for(int i=pos-1;i>=0;i--) {
        if(a[i] < a[i+1]) {
            cout << '1' << " " << i+1 << " " << i+2 << endl;
        }
        a[i] = a[i+1];
    }
    for(int i=0;i<n-1;i++) {
        if(a[i+1] != mx) {
            a[i] = mx;
            cout << 1 + (a[i+1] > a[i]) << " " << i+2 << " " << i+1 << endl;
            a[i+1] = a[i];
        }
    }
    return ;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve() {
   int n;
   cin >> n;
   int a[n];
   int f[100005] = {0};
   int f1[100005] = {0};
   int mx = 0;
   cin >> a[0];
   f1[a[0]]++;
    for(int i=1;i<n;i++) {
        cin >> a[i];
        f1[a[i]]++;
        f[abs(a[i]-a[i-1])]++;
    }
    for(int i=0;i<n;i++) {
        if(f1[a[i]]) {
            if(f1[a[i]] > f1[mx])
            mx = a[i];
        }
    }
   // cout << f1[a[0]] << endl;
    if(f1[a[0]] == n) {
        cout << '0' << endl;
        return ;
    }
    int mx1 = 0;
    for(int i=0;i<100005;i++) {
        if(f[i]) {
            if(f[i] > mx1)
                mx1 = f[i];
        }
    }
    for(int i=0;i<n;i++) {
        if(a[i] == max(mx, mx1))
            continue;
        else if(a[i] < max(mx, mx1)) {
            cout << '1' << " " << i+1 << " " << i+2 << endl;
        }
        else {
            cout << '2' << " " << i+1 << " " << i << endl;
        }
    }
    return ;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve() {
   int n;
   cin >> n;
   int a[n];
   int f[100005] = {0};
   int f1[100005] = {0};
   int mx = 0;
   cin >> a[0];
   f1[a[0]]++;
    for(int i=1;i<n;i++) {
        cin >> a[i];
        f1[a[i]]++;
        f[abs(a[i]-a[i-1])]++;
    }
    for(int i=0;i<n;i++) {
        if(f1[a[i]]) {
            if(f1[a[i]] > f1[mx])
            mx = a[i];
        }
    }
   // cout << f1[a[0]] << endl;
    if(f1[a[0]] == n) {
        cout << '0' << endl;
        return ;
    }
    int mx1 = 0;
    for(int i=0;i<100005;i++) {
        if(f[i]) {
            if(f[i] > mx1)
                mx1 = f[i];
        }
    }
    cout << n - f1[max(mx, mx1)] << endl;
    for(int i=0;i<n;i++) {
        if(a[i] == max(mx, mx1))
            continue;
        else if(a[i] < max(mx, mx1)) {
            cout << '1' << " " << i+1 << " " << i+2 << endl;
        }
        else {
            cout << '2' << " " << i+1 << " " << i << endl;
        }
    }
    return ;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve() {
   int n;
   cin >> n;
   int a[n];
   int f[200005] = {0};
    for(int i=0;i<n;i++) {
        cin >> a[i];
        f[a[i]]++;
    }
    int mx = 0;
    for(int i=0;i<n;i++) {
        if(f[a[i]]) {
            if(f[a[i]] > f[mx])
                mx = a[i];
        }
    }
    int pos;
    for(int i=0;i<n;i++) {
        if(a[i] == mx) {
            pos = i;
            break;
        }
    }
    cout << n - f[mx] << endl;
    for(int i=pos-1;i>=0;i--) {
            cout << 1 + (a[i] > a[i+1]) << " " << i+1 << " " << i+2 << endl;
        a[i] = a[i+1];
    }
    for(int i=0;i<n-1;i++) {
        if(a[i+1] != mx) {
            a[i] = mx;
            cout << 1 + (a[i+1] > a[i]) << " " << i+2 << " " << i+1 << endl;
            a[i+1] = a[i];
        }
    }
    return ;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve() {
   int n;
   cin >> n;
   int a[n];
   int f[100005] = {0};
    for(int i=0;i<n;i++) {
        cin >> a[i];
        f[a[i]]++;
    }
    int mx = 0;
    for(int i=0;i<n;i++) {
        if(f[a[i]]) {
            if(f[a[i]] > f[mx])
                mx = a[i];
        }
    }
    cout << n - f[mx] << endl;
    int count = 0;
    while(count < n - f[mx]) {
    for(int i=0;i<n-1;i++) {
        if(a[i] == mx)
            continue;
        else if(a[i] < mx) {
            if(a[i] + abs(a[i+1] - a[i]) == mx) {
                cout << '1' << " " << i+1 << " " << i+2 << endl;
            }
            a[i] = a[i] + (abs(a[i+1]-a[i]));
        }
        else {
            if(a[i] - abs(a[i] - a[i-1]) == mx) {
                cout << '2' << " " << i+1 << " " << i << endl;
            }
            a[i] = a[i] - (abs(a[i-1]-a[i]));
        }
    }
    count++;
    }
    return ;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve() {
   int n;
   cin >> n;
   int a[n];
   int f[200005] = {0};
    for(int i=0;i<n;i++) {
        cin >> a[i];
        f[a[i]]++;
    }
    int mx = 0;
    for(int i=0;i<n;i++) {
        if(f[a[i]]) {
            if(f[a[i]] > f[mx])
                mx = a[i];
        }
    }
    cout << n - f[mx] << endl;
    int count = 0;
    while(count < n - f[mx]) {
    for(int i=0;i<n;i++) {
        if(a[i] == mx)
            continue;
        else if(a[i] < mx) {
            if(i == n-1) {
                break;
            }
            if(a[i] + abs(a[i+1] - a[i]) == mx) {
                cout << '1' << " " << i+1 << " " << i+2 << endl;
            }
            a[i] = a[i] + (abs(a[i+1]-a[i]));
        }
        else {
            if(a[i] - abs(a[i] - a[i-1]) == mx) {
                cout << '2' << " " << i+1 << " " << i << endl;
            }
            a[i] = a[i] - (abs(a[i-1]-a[i]));
        }
    }
    count++;
    }
    return ;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve() {
   int n;
   cin >> n;
   int a[n];
   int f[100005] = {0};
    for(int i=0;i<n;i++) {
        cin >> a[i];
        f[a[i]]++;
    }
    int mx = 0;
    for(int i=0;i<n;i++) {
        if(f[a[i]]) {
            if(f[a[i]] > f[mx])
                mx = a[i];
        }
    }
    cout << n - f[mx] << endl;
    int count = 0;
    while(count < n - f[mx]) {
    for(int i=0;i<n;i++) {
        if(a[i] == mx)
            continue;
        else if(a[i] < mx) {
            if(i == n-1) {
                break;
            }
            if(a[i] + abs(a[i+1] - a[i]) == mx) {
                cout << '1' << " " << i+1 << " " << i+2 << endl;
            }
            a[i] = a[i] + (abs(a[i+1]-a[i]));
        }
        else {
            if(a[i] - abs(a[i] - a[i-1]) == mx) {
                cout << '2' << " " << i+1 << " " << i << endl;
            }
            a[i] = a[i] - (abs(a[i-1]-a[i]));
        }
    }
    count++;
    }
    return ;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve() {
   int n;
   cin >> n;
   int a[n];
   int f[200005] = {0};
    for(int i=0;i<n;i++) {
        cin >> a[i];
        f[a[i]]++;
    }
    int mx = 0;
    for(int i=0;i<n;i++) {
        if(f[a[i]]) {
            if(f[a[i]] > f[mx])
                mx = a[i];
        }
    }
    int pos;
    for(int i=0;i<n;i++) {
        if(a[i] == mx) {
            pos = i;
            break;
        }
    }
    cout << n - f[mx] << endl;
    for(int i=pos-1;i>=0;i--) {
        if(a[i] + abs(a[i+1] - a[i]) == mx) {
            cout << '1' << " " << i+1 << " " << i+2 << endl;
        }
        a[i] = a[i+1];
    }
    for(int i=0;i<n-1;i++) {
        if(a[i+1] != mx) {
            cout << 1 + (a[i+1] > a[i]) << " " << i+2 << " " << i+1 << endl;
            a[i+1] = a[i];
        }
    }
    return ;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
   // freopen("input.txt","r",stdin);
   vector< pair<int,pair<int,int> > >v;
   unordered_map<int,int>m;
int n;
cin>>n;
int ar[n];
for(int i=0;i<n;i++){
    cin>>ar[i];
    m[ar[i]]++;
}
int mx=0;
int k;
for(int i=0;i<=300000;i++){
    if(m[i]>mx){
        mx=m[i];
        k=i;
    }
}
for(int i=0;i<n;i++){
    if(ar[i]==k && i!=n-1){
        for(int j=i+1;j<n;j++){
            if(ar[j]<k){
                v.push_back(make_pair(1,make_pair(j+1,j)));
                ar[j]=k;
            }
            else if(ar[j]>k){
                v.push_back(make_pair(2,make_pair(j+1,j)));
                ar[j]=k;
            }
        }
    }
    break;
}
for(int i=n-1;i>=0;i--){
    if(ar[i]==k && i!=0){
        for(int j=i-1;j>=0;j--){
            if(ar[j]<k){
                v.push_back(make_pair(1,make_pair(j+1,j+2)));
            }
            else if(ar[j]>k){
                v.push_back(make_pair(2,make_pair(j+1,j+2)));
            }
        }
    }
    break;
}
cout<<v.size()<<endl;
for(int i=0;i<v.size();i++){
    cout<<v[i].first<<" "<<v[i].second.first<<" "<<v[i].second.second<<endl;
}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
   // freopen("input.txt","r",stdin);
   vector< pair<long long int,pair<long long int,long long int> > >v;
   unordered_map<long long int,long long int>m;
long long int n;
cin>>n;
long long int ar[n];
for(long long int i=0;i<n;i++){
    cin>>ar[i];
    m[ar[i]]++;
}
long long int mx=0;
long long int k;
for(long long int i=0;i<=300000;i++){
    if(m[i]>mx){
        mx=m[i];
        k=i;
    }
}
for(long long int i=0;i<n;i++){
    if(ar[i]==k && i!=n-1){
        for(long long int j=i+1;j<n;j++){
            if(ar[j]<k){
                v.push_back(make_pair(1,make_pair(j+1,j)));
                ar[j]=k;
            }
            else if(ar[j]>k){
                v.push_back(make_pair(2,make_pair(j+1,j)));
                ar[j]=k;
            }
        }
    }
    break;
}
for(long long int i=n-1;i>=0;i--){
    if(ar[i]==k && i!=0){
        for(long long int j=i-1;j>=0;j--){
            if(ar[j]<k){
                v.push_back(make_pair(1,make_pair(j+1,j+2)));
            }
            else if(ar[j]>k){
                v.push_back(make_pair(2,make_pair(j+1,j+2)));
            }
        }
    }
    break;
}
cout<<v.size()<<endl;
for(long long int i=0;i<v.size();i++){
    cout<<v[i].first<<" "<<v[i].second.first<<" "<<v[i].second.second<<endl;
}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
   // freopen("input.txt","r",stdin);
   vector< pair<long long int,pair<long long int,long long int> > >v;
   map<long long int,long long int>m;
long long int n;
cin>>n;
long long int ar[n];
for(long long int i=0;i<n;i++){
    cin>>ar[i];
    m[ar[i]]++;
}
long long int mx=0;
long long int k;
for(long long int i=0;i<=3000000;i++){
    if(m[i]>mx){
        mx=m[i];
        k=i;
    }
}
for(long long int i=0;i<n;i++){
    if(ar[i]==k && i!=n-1){
        for(long long int j=i+1;j<n;j++){
            if(ar[j]<k){
                v.push_back(make_pair(1,make_pair(j+1,j)));
                ar[j]=k;
            }
            else if(ar[j]>k){
                v.push_back(make_pair(2,make_pair(j+1,j)));
                ar[j]=k;
            }
        }
    }
    break;
}
for(long long int i=n-1;i>=0;i--){
    if(ar[i]==k && i!=0){
        for(long long int j=i-1;j>=0;j--){
            if(ar[j]<k){
                v.push_back(make_pair(1,make_pair(j+1,j+2)));
            }
            else if(ar[j]>k){
                v.push_back(make_pair(2,make_pair(j+1,j+2)));
            }
        }
    }
    break;
}
cout<<v.size()<<endl;
for(long long int i=0;i<v.size();i++){
    cout<<v[i].first<<" "<<v[i].second.first<<" "<<v[i].second.second<<endl;
}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
    // freopen("input.txt","r",stdin);
    vector< pair<long long int,pair<long long int,long long int> > >v;
    unordered_map<long long int,long long int>m;
    long long int n;
    cin>>n;
    long long int ar[n];
    long long int k;
    long long int mx=0;
    for(long long int i=0;i<n;i++){
        cin>>ar[i];
        m[ar[i]]++;
        if(m[ar[i]]>mx){
            mx=m[ar[i]];
            k=i;
        }
    }
    if(k!=n-1) {
        for (long long int i = k+1; i < n; i++) {
                    if (ar[i] < ar[k]) {
                        v.push_back(make_pair(1, make_pair(i + 1, i)));
                        ar[i] = ar[k];
                    } else if (ar[i] > ar[k]) {
                        v.push_back(make_pair(2, make_pair(i + 1, i)));
                        ar[i] = ar[k];
                    }
        }
    }
    if(k!=0) {
        for (long long int i = k-1; i >= 0; i--) {
                    if (ar[i] < ar[k]) {
                        v.push_back(make_pair(1, make_pair(i + 1, i+2)));
                    }
                    else if (ar[i] > ar[k]) {
                        v.push_back(make_pair(2, make_pair(i + 1, i+2)));
                    }
        }
    }
    cout<<v.size()<<endl;
    for(long long int i=0;i<v.size();i++){
        cout<<v[i].first<<" "<<v[i].second.first<<" "<<v[i].second.second<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
   // freopen("input.txt","r",stdin);
   vector< pair<long long int,pair<long long int,long long int> > >v;
   unordered_map<long long int,long long int>m;
long long int n;
cin>>n;
long long int ar[n];
for(long long int i=0;i<n;i++){
    cin>>ar[i];
    m[ar[i]]++;
}
long long int mx=0;
long long int k;
for(long long int i=0;i<=3000000;i++){
    if(m[i]>mx){
        mx=m[i];
        k=i;
    }
}
for(long long int i=0;i<n;i++){
    if(ar[i]==k && i!=n-1){
        for(long long int j=i+1;j<n;j++){
            if(ar[j]<k){
                v.push_back(make_pair(1,make_pair(j+1,j)));
                ar[j]=k;
            }
            else if(ar[j]>k){
                v.push_back(make_pair(2,make_pair(j+1,j)));
                ar[j]=k;
            }
        }
    }
    break;
}
for(long long int i=n-1;i>=0;i--){
    if(ar[i]==k && i!=0){
        for(long long int j=i-1;j>=0;j--){
            if(ar[j]<k){
                v.push_back(make_pair(1,make_pair(j+1,j+2)));
            }
            else if(ar[j]>k){
                v.push_back(make_pair(2,make_pair(j+1,j+2)));
            }
        }
    }
    break;
}
cout<<v.size()<<endl;
for(long long int i=0;i<v.size();i++){
    cout<<v[i].first<<" "<<v[i].second.first<<" "<<v[i].second.second<<endl;
}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
   // freopen("input.txt","r",stdin);
   vector< pair<int,pair<int,int> > >v;
   unordered_map<int,int>m;
int n;
cin>>n;
int ar[n];
for(int i=0;i<n;i++){
    cin>>ar[i];
    m[ar[i]]++;
}
int mx=0;
int k;
for(int i=0;i<=300000;i++){
    if(m[i]>mx){
        mx=m[i];
        k=i;
    }
}
for(int i=0;i<n;i++){
    if(ar[i]==k && i!=n-1){
        for(int j=i+1;j<n;j++){
            if(ar[j]<k){
                v.push_back(make_pair(1,make_pair(j,j+1)));
                ar[j]=k;
            }
            else if(ar[j]>k){
                v.push_back(make_pair(2,make_pair(j,j+1)));
                ar[j]=k;
            }
        }
    }
    break;
}
for(int i=n-1;i>=0;i--){
    if(ar[i]==k && i!=0){
        for(int j=i-1;j>=0;j--){
            if(ar[j]<k){
                v.push_back(make_pair(1,make_pair(j+1,j+2)));
            }
            else if(ar[j]>k){
                v.push_back(make_pair(2,make_pair(j+1,j+2)));
            }
        }
    }
    break;
}
cout<<v.size()<<endl;
for(int i=0;i<v.size();i++){
    cout<<v[i].first<<" "<<v[i].second.first<<" "<<v[i].second.second<<endl;
}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
    // freopen("input.txt","r",stdin);
    vector< pair<long long int,pair<long long int,long long int> > >v;
    unordered_map<long long int,long long int>m;
    long long int n;
    cin>>n;
    long long int ar[n];
    long long int k;
    long long int mx=0;
    for(long long int i=0;i<n;i++){
        cin>>ar[i];
        m[ar[i]]++;
        if(m[ar[i]]>mx){
            mx=m[ar[i]];
            k=ar[i];
        }
    }
    for(long long int i=0;i<n;i++){
        if(ar[i]==k && i!=n-1){
            for(long long int j=i+1;j<n;j++){
                if(ar[j]<k){
                    v.push_back(make_pair(1,make_pair(j+1,j)));
                    ar[j]=k;
                }
                else if(ar[j]>k){
                    v.push_back(make_pair(2,make_pair(j+1,j)));
                    ar[j]=k;
                }
            }
        }
        break;
    }
    for(long long int i=n-1;i>=0;i--){
        if(ar[i]==k && i!=0){
            for(long long int j=i-1;j>=0;j--){
                if(ar[j]<k){
                    v.push_back(make_pair(1,make_pair(j+1,j+2)));
                }
                else if(ar[j]>k){
                    v.push_back(make_pair(2,make_pair(j+1,j+2)));
                }
            }
        }
        break;
    }
    cout<<v.size()<<endl;
    for(long long int i=0;i<v.size();i++){
        cout<<v[i].first<<" "<<v[i].second.first<<" "<<v[i].second.second<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
   // freopen("input.txt","r",stdin);
   vector< pair<long long int,long long int> >v;
long long int n;
cin>>n;
long long int ar[n];
for(long long int i=0;i<n;i++){
    cin>>ar[i];
}
for(long long int i=1;i<n;i++){
    if(ar[i]!=ar[i-1]){
        v.push_back(make_pair(i,i+1));
        if(ar[i]<ar[i-1]){
            ar[i]=ar[i-1];
        }
        else{
            ar[i-1]=ar[i];
        }
    }
}
cout<<v.size()<<endl;
for(long long int i=0;i<v.size();i++){
    cout<<1<<" "<<v[i].first<<" "<<v[i].second<<endl;
}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
    // freopen("input.txt","r",stdin);
    vector< pair<long long int,pair<long long int,long long int> > >v;
    unordered_map<long long int,long long int>m;
    long long int n;
    cin>>n;
    long long int ar[n];
    long long int k=0;
    long long int mx=0;
    for(long long int i=0;i<n;i++){
        cin>>ar[i];
        m[ar[i]]++;
        if(m[ar[i]]>mx){
            mx=m[ar[i]];
            k=ar[i];
        }
    }
    for(long long int i=0;i<n;i++){
        if(ar[i]==k && i!=n-1){
            for(long long int j=i+1;j<n;j++){
                if(ar[j]<k){
                    v.push_back(make_pair(1,make_pair(j+1,j)));
                    ar[j]=k;
                }
                else if(ar[j]>k){
                    v.push_back(make_pair(2,make_pair(j+1,j)));
                    ar[j]=k;
                }
            }
        }
        break;
    }
    for(long long int i=n-1;i>=0;i--){
        if(ar[i]==k && i!=0){
            for(long long int j=i-1;j>=0;j--){
                if(ar[j]<k){
                    v.push_back(make_pair(1,make_pair(j+1,j+2)));
                }
                else if(ar[j]>k){
                    v.push_back(make_pair(2,make_pair(j+1,j+2)));
                }
            }
        }
        break;
    }
    cout<<v.size()<<endl;
    for(long long int i=0;i<v.size();i++){
        cout<<v[i].first<<" "<<v[i].second.first<<" "<<v[i].second.second<<endl;
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>

#define ll long long
const int nax = 2e5+5;
using namespace std;

int main() {
	int n, cnt[nax]{0};
	int x, p, m=0;
	scanf("%d", &n);
	vector<int>a(n+1);
	for(int i=1; i<=n; i++){
	    scanf("%d", &a[i]);
	    cnt[a[i]]++;
	    if(cnt[a[i]]>=m){m = cnt[a[i]]; x = a[i]; p = i;}
	}
	printf("%d\n", n-m);
	for(int i=p-1; i>0; i--){
	    if(a[i]>x){
	        a[i] = a[i+1];
	        printf("%d %d %d\n", 2, i, i+1);
	    }
	    else if(a[i]<x){
	        a[i] = a[i+1];
	        printf("%d %d %d\n", 1, i, i+1);
	    }
	}
	for(int i=1; i<n; i++){
	    if(a[i]>x){
	        a[i+1] = a[i];
	        printf("%d %d %d\n", 2, i+1, i);
	    }
	    else if(a[i]<x){
	        a[i+1] = a[i];
	        printf("%d %d %d\n", 1, i+1, i);
	    }
	}

}


#include <iostream>
#include <algorithm>
#include <vector>

#define ll long long
const int nax = 2e5+5;
using namespace std;

int main() {
	int n;
	int x, p, m=0;
	scanf("%d", &n);
	vector<int>a(n+1), cnt(nax, 0);
	for(int i=1; i<=n; i++){
	    scanf("%d", &a[i]);
	    cnt[a[i]]++;
	}
	x = max_element(cnt.begin(), cnt.end()) - cnt.begin();
	p = find(a.begin(), a.end(), x) - a.begin();
	m = cnt[x];

	printf("%d\n", n-m);
	for(int i=p-1; i>0; i--){
	        printf("%d %d %d\n", 1 + (a[i]>a[i+1]), i, i+1);
	        a[i] = a[i+1];
	}
	for(int i=1; i<n; i++){
	    if(a[i+1]!=x){
	        printf("%d %d %d\n", 1 + (a[i+1]>a[i]), i+1, i);
	        a[i+1] = a[i];
	    }

	}

}


#include <iostream>
#include <algorithm>
#include <vector>

#define ll long long
const int nax = 2e5+5;
using namespace std;

int main() {
	int n;
	int x, p, m=0;
	scanf("%d", &n);
	vector<int>a(n), cnt(nax, 0);
	for(int& i:a){
	    scanf("%d", &i);
	    cnt[i]++;
	}
	x = max_element(cnt.begin(), cnt.end()) - cnt.begin();
	p = find(a.begin(), a.end(), x) - a.begin();
	m = cnt[x];

	printf("%d\n", n-m);
	for(int i=p-1; i>=0; i--){
	        printf("%d %d %d\n", 1 + (a[i]>a[i+1]), i+1, i+2);
	        a[i] = a[i+1];
	}
	for(int i=0; i<n-1; i++){
	    if(a[i+1]!=x){
	        printf("%d %d %d\n", 1 + (a[i+1]>a[i]), i+2, i+1);
	        a[i+1] = a[i];
	    }

	}

}


#include <iostream>
#include <algorithm>
#include <vector>

#define ll long long
const int nax = 2e5+5;
using namespace std;

int main() {
	int n, cnt[nax];
	int x, p, m=0;
	scanf("%d", &n);
	vector<ll>a(n+1);
	for(int i=1; i<=n; i++){
	    scanf("%lld", &a[i]);
	    cnt[a[i]]++;
	    if(cnt[a[i]]>=m){m = cnt[a[i]]; x = a[i]; p = i;}
	}
	printf("%d\n", n-m);
	for(int i=p-1; i>0; i--){
	    if(a[i]>x){
	        a[i] -= abs(a[i] - a[i+1]);
	        printf("%lld %lld %lld\n", 2, i, i+1);
	    }
	    else if(a[i]<x){
	        a[i] += abs(a[i] - a[i+1]);
	        printf("%d %d %d\n", 1, i, i+1);
	    }
	}
	for(int i=1; i<=n; i++){
	    if(a[i]>x){
	        a[i] -= abs(a[i] - a[i+1]);
	        printf("%d %d %d\n", 2, i, i+1);
	    }
	    else if(a[i]<x){
	        a[i] += abs(a[i] - a[i+1]);
	        printf("%d %d %d\n", 1, i, i+1);
	    }
	}

}


#include <iostream>
#include <algorithm>
#include <vector>

#define ll long long
const int nax = 2e5+5;
using namespace std;

int main() {
	int n;
	int x, p, m=0;
	scanf("%d", &n);
	vector<int>a(n), cnt(nax, 0);
	for(int& i:a){
	    scanf("%d", &i);
	    cnt[i]++;
	}
	x = max_element(cnt.begin(), cnt.end()) - cnt.begin();
	p = find(a.begin(), a.end(), x) - a.begin();
	m = cnt[x];

	printf("%d\n", n-m);
	for(int i=p-1; i>=0; i--){
	        printf("%d %d %d\n", 1 + (a[i]>a[i+1]), i+1, i+2);
	        a[i] = a[i+1];
	}
	for(int i=1; i<n; i++){
	    if(a[i+1]!=x){
	        printf("%d %d %d\n", 1 + (a[i+1]>a[i]), i+2, i+1);
	        a[i+1] = a[i];
	    }

	}

}


#include <iostream>
#include <algorithm>
#include <vector>

#define ll long long
const int nax = 2e5+5;
using namespace std;

int main() {
	int n, cnt[nax];
	int x, p, m=0;
	scanf("%d", &n);
	vector<ll>a(n+1);
	for(int i=1; i<=n; i++){
	    scanf("%d", &a[i]);
	    cnt[a[i]]++;
	    if(cnt[a[i]]>=m){m = cnt[a[i]]; x = a[i]; p = i;}
	}
	printf("%d\n", n-m);
	for(int i=p-1; i>0; i--){
	    if(a[i]>x){
	        a[i] -= abs(a[i] - a[i+1]);
	        printf("%d %d %d\n", 2, i, i+1);
	    }
	    else if(a[i]<x){
	        a[i] += abs(a[i] - a[i+1]);
	        printf("%d %d %d\n", 1, i, i+1);
	    }
	}
	for(int i=1; i<=n; i++){
	    if(a[i]>x){
	        a[i] -= abs(a[i] - a[i+1]);
	        printf("%d %d %d\n", 2, i, i+1);
	    }
	    else if(a[i]<x){
	        a[i] += abs(a[i] - a[i+1]);
	        printf("%d %d %d\n", 1, i, i+1);
	    }
	}

}


#include <iostream>
#include <algorithm>
#include <vector>

#define ll long long
const int nax = 2e5+5;
using namespace std;

int main() {
	int n;
	int x, p, m=0;
	scanf("%d", &n);
	vector<int>a(n+1), cnt(nax);
	for(int i=1; i<=n; i++){
	    scanf("%d", &a[i]);
	    cnt[a[i]]++;
	    //if(cnt[a[i]]>=m){m = cnt[a[i]]; x = a[i]; }
	}
	x = max_element(cnt.begin(), cnt.end()) - cnt.begin();
	p = find(a.begin(), a.end(), x) - a.begin();
	m = cnt[x];

	printf("%d\n", n-m);
	for(int i=p-1; i>0; i--){
	        printf("%d %d %d\n", 1 + (a[i]>a[i+1]), i, i+1);
	        a[i] = a[i+1];
	}
	for(int i=1; i<n; i++){
	    if(a[i+1]!=x){
	        printf("%d %d %d\n", 1 + (a[i+1]>a[i]), i+1, i);
	        a[i+1] = a[i];
	    }

	}

}


#include <iostream>
#include <algorithm>
#include <vector>

#define ll long long
const int nax = 2e5+5;
using namespace std;

int main() {
	int n;
	int x, p, m=0;
	scanf("%d", &n);
	vector<int>a(n+1), cnt(nax);
	for(int i=1; i<=n; i++){
	    scanf("%d", &a[i]);
	    cnt[a[i]]++;
	    //if(cnt[a[i]]>=m){m = cnt[a[i]]; x = a[i]; }
	}
	x = max_element(cnt.begin(), cnt.end()) - cnt.begin();
	p = find(a.begin(), a.end(), x) - a.begin();
	m = cnt[x];

	printf("%d\n", n-m);
	for(int i=p-1; i>0; i--){
	        printf("%d %d %d\n", 1 + (a[i]>x), i, i+1);
	        a[i] = a[i+1];
	}
	for(int i=1; i<n; i++){
	    if(a[i+1]!=x){
	        printf("%d %d %d\n", 1 + a[i]>x, i+1, i);
	        a[i+1] = a[i];
	    }

	}

}


#include <iostream>
#include <algorithm>
#include <vector>

#define ll long long
const int nax = 2e5+5;
using namespace std;

int main() {
	int n, cnt[nax];
	int x, p, m=0;
	scanf("%d", &n);
	vector<ll>a(n+1);
	for(int i=1; i<=n; i++){
	    scanf("%lld", &a[i]);
	    cnt[a[i]]++;
	    if(cnt[a[i]]>=m){m = cnt[a[i]]; x = a[i]; p = i;}
	}
	printf("%d\n", n-m);
	for(int i=p-1; i>0; i--){
	    if(a[i]>x){
	        a[i] = a[i+1];
	        printf("%lld %lld %lld\n", 2, i, i+1);
	    }
	    else if(a[i]<x){
	        a[i] = a[i+1];
	        printf("%d %d %d\n", 1, i, i+1);
	    }
	}
	for(int i=1; i<n; i++){
	    if(a[i]>x){
	        a[i+1] = a[i];
	        printf("%d %d %d\n", 2, i+1, i);
	    }
	    else if(a[i]<x){
	        a[i+1] = a[i];
	        printf("%d %d %d\n", 1, i+1, i);
	    }
	}

}


#include <iostream>
#include <algorithm>
#include <vector>

#define ll long long
const int nax = 2e5+5;
using namespace std;

int main() {
	int n;
	int x, p, m=0;
	scanf("%d", &n);
	vector<int>a(n+1), cnt(nax, 0);
	for(int i=1; i<=n; i++){
	    scanf("%d", &a[i]);
	    cnt[a[i]]++;
	}
	x = max_element(cnt.begin(), cnt.end()) - cnt.begin();
	p = find(a.begin(), a.end(), x) - a.begin() - 1;
	m = cnt[x];

	printf("%d\n", n-m);
	for(int i=p-1; i>0; i--){
	        printf("%d %d %d\n", 1 + (a[i]>a[i+1]), i, i+1);
	        a[i] = a[i+1];
	}
	for(int i=1; i<n; i++){
	    if(a[i+1]!=x){
	        printf("%d %d %d\n", 1 + (a[i+1]>a[i]), i+1, i);
	        a[i+1] = a[i];
	    }

	}

}


#include <iostream>
#include <algorithm>
#include <vector>

#define ll long long
const int nax = 2e5+5;
using namespace std;

int main() {
	int n, cnt[nax];
	int x, p, m=0;
	scanf("%d", &n);
	vector<ll>a(n+1);
	for(int i=1; i<=n; i++){
	    scanf("%lld", &a[i]);
	    cnt[a[i]]++;
	    if(cnt[a[i]]>=m){m = cnt[a[i]]; x = a[i]; p = i;}
	}
	printf("%d\n", n-m);
	for(int i=p-1; i>0; i--){
	    if(a[i]>x){
	        a[i] = a[i+1];
	        printf("%lld %lld %lld\n", 2, i, i+1);
	    }
	    else if(a[i]<x){
	        a[i] = a[i+1];
	        printf("%d %d %d\n", 1, i, i+1);
	    }
	}
	for(int i=1; i<=n; i++){
	    if(a[i]>x){
	        a[i+1] = a[i];
	        printf("%d %d %d\n", 2, i+1, i);
	    }
	    else if(a[i]<x){
	        a[i+1] = a[i];
	        printf("%d %d %d\n", 1, i+1, i);
	    }
	}

}


#include <iostream>
#include <algorithm>
#include <vector>

#define ll long long
const int nax = 2e5+5;
using namespace std;

int main() {
	int n, cnt[nax]{0};
	int x, p, m=0;
	scanf("%d", &n);
	vector<int>a(n+1);
	for(int i=1; i<=n; i++){
	    scanf("%d", &a[i]);
	    cnt[a[i]]++;
	    if(cnt[a[i]]>=m){m = cnt[a[i]]; x = a[i]; p = i;}
	}
	printf("%d\n", n-m);
	for(int i=p-1; i>0; i--){
	        a[i] = a[i+1];
	        printf("%d %d %d\n", 1 + a[i]>x, i, i+1);
	 	}
	for(int i=1; i<n; i++){
	    if(a[i]!=x){
	        a[i+1] = a[i];
	        printf("%d %d %d\n", 1 + a[i]>x, i+1, i);
	    }

	}

}


#include <iostream>
#include <algorithm>
#include <vector>

#define ll long long
const int nax = 2e5+5;
using namespace std;

int main() {
	int n;
	int x, p, m=0;
	scanf("%d", &n);
	vector<int>a(n), cnt(nax, 0);
	for(int& i:a){
	    scanf("%d", &i);
	    cnt[i]++;
	}
	x = max_element(cnt.begin(), cnt.end()) - cnt.begin();
	p = find(a.begin(), a.end(), x) - a.begin();
	m = cnt[x];

	printf("%d\n", n-m);
	for(int i=p-1; i>=0; i--){
	        printf("%d %d %d\n", 1 + (a[i]>a[i+1]), i+1, i+2);
	        a[i] = a[i+1];
	}
	for(int i=1; i<n-1; i++){
	    if(a[i+1]!=x){
	        printf("%d %d %d\n", 1 + (a[i+1]>a[i]), i+2, i+1);
	        a[i+1] = a[i];
	    }

	}

}


#include <iostream>
#include <algorithm>
#include <vector>

#define ll long long
const int nax = 2e5+5;
using namespace std;

int main() {
	int n;
	int x, p, m=0;
	scanf("%d", &n);
	vector<int>a(n+1), cnt(nax);
	for(int i=1; i<=n; i++){
	    scanf("%d", &a[i]);
	    cnt[a[i]]++;
	    //if(cnt[a[i]]>=m){m = cnt[a[i]]; x = a[i]; }
	}
	x = max_element(cnt.begin(), cnt.end()) - cnt.begin();
	p = find(a.begin(), a.end(), x) - a.begin();
	m = cnt[x];
	printf("%d\n", n-m);
	for(int i=p-1; i>0; i--){
	        printf("%d %d %d\n", 1 + (a[i]>x), i, i+1);
	        a[i] = a[i+1];
	}
	for(int i=1; i<n; i++){
	    if(a[i]!=x){
	        printf("%d %d %d\n", 1 + a[i]>x, i+1, i);
	        a[i+1] = a[i];
	    }

	}

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define vli vector<ll>
#define pb push_back
#define comp(v) v.begin(),v.end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
const int M = 1e9+7;
const int N = 2e5;
ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}
void solve(){
    int n;cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<pair<int,pair<int,int>>> v;
    for(int i=n-2;i>=0;i--){
        if(a[i]==a[i+1]) continue;
        ll d = abs(a[i]-a[i+1]);
        if(a[i]<a[i+1]){
            a[i] += d;
            v.pb({1,{i+1,i+2}});
        }
        else{
            a[i]-=d;
            v.pb({2,{i+1,i+2}});
        }
    }
    cout<<v.size()<<"\n";
    for(auto i:v){
        cout<<i.ff<<" ";
        cout<<i.ss.ff<<" "<<i.ss.ss<<"\n";
    }

}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
   // cin>>t;
    while(t--){
        solve();
    }

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define vli vector<ll>
#define pb push_back
#define comp(v) v.begin(),v.end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
const int M = 1e9+7;
const int N = 2e5;
ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}
void solve(){
    int n;cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<pair<int,pair<int,int>>> v,p;
    for(int i=n-2;i>=0;i--){
        if(a[i]==a[i+1]) continue;
        ll d = abs(a[i]-a[i+1]);
        if(a[i]<a[i+1]){
            a[i] += d;
            v.pb({1,{i+1,i+2}});
        }
        else{
            a[i]-=d;
            v.pb({2,{i+1,i+2}});
        }
    }
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]) continue;
        ll d = abs(a[i]-a[i-1]);
        if(a[i]<a[i-1]){
            a[i] += d;
            p.pb({1,{i+1,i}});
        }
        else{
            a[i]-=d;
            p.pb({2,{i+1,i}});
        }
    }
    if(v.size()<p.size()){
    cout<<v.size()<<"\n";
    for(auto i:v){
        cout<<i.ff<<" ";
        cout<<i.ss.ff<<" "<<i.ss.ss<<"\n";
    }
    }
    else{
        cout<<p.size()<<"\n";
    for(auto i:p){
        cout<<i.ff<<" ";
        cout<<i.ss.ff<<" "<<i.ss.ss<<"\n";
    }
    }

}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
   // cin>>t;
    while(t--){
        solve();
    }

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define comp(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvli;
const int M = 1e9+7;
const int N = 1e6;
ll po(int,int);

void solve(){
   int n;cin>>n;
   int a[n];
   map<int,int> m;
   int mx = -1,el=-1;
   FOR(i,0,n){
       cin>>a[i];
       m[a[i]]++;
       if(m[a[i]]>mx){
           mx=m[a[i]];
           el = a[i];
       }
   }
   int l=-1,r=-1;
   FOR(i,0,n){
       if(a[i]==el){
           l=i;
           break;
       }
   }
   ROF(i,n-1,0){
       if(a[i]==el){
           r=i;
           break;
       }
   }
   if(n==1) cout<<0<<"\n";
   else{
       vector<pair<int,pair<int,int>>> p;
       ROF(i,l-1,0){
           int d = a[i]-a[i+1];
           if(d<0){
               p.pb({1,{i+1,i+2}});
           }
           else{
               p.pb({2,{i+1,i+2}});
           }
       }
       FOR(i,r+1,n){
           int d = a[i]-a[i-1];
           if(d<0){
               p.pb({1,{i+1,i}});
           }
           else{
               p.pb({2,{i+1,i}});
           }
       }
       cout<<p.size()<<"\n";
       for(auto i:p){
           cout<<i.ff<<" "<<i.ss.ff<<" "<<i.ss.ss<<"\n";
       }
   }

}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }

	return 0;

}

ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define comp(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvli;
const int M = 1e9+7;
const int N = 1e6;
ll po(int,int);

void solve(){
   int n;cin>>n;
   int a[n];
   map<int,int> m;
   int mx = -1,el=-1;
   FOR(i,0,n){
       cin>>a[i];
       m[a[i]]++;
       if(m[a[i]]>mx){
           mx=m[a[i]];
           el = a[i];
       }
   }
   int l=-1,r=-1;
   FOR(i,0,n){
       if(a[i]==el){
           l=i;
       }
   }
   ROF(i,n-1,0){
       if(a[i]==el){
           r=i;
       }
   }
   if(n==1) cout<<0<<"\n";
   else{
       vector<pair<int,pair<int,int>>> p;
       ROF(i,l-1,0){
           int d = a[i]-a[i+1];
           if(d<0){
               p.pb({1,{i+1,i+2}});
               a[i]=a[i+1];
           }
           else if(d>0){
               p.pb({2,{i+1,i+2}});
               a[i]=a[i+1];
           }
       }
       FOR(i,r+1,n){
           int d = a[i]-a[i-1];
           if(d<0){
               p.pb({1,{i+1,i}});
               a[i]=a[i-1];
           }
           else if(d>0){
               p.pb({2,{i+1,i}});
               a[i]=a[i-1];
           }
       }
       cout<<p.size()<<"\n";
       for(auto i:p){
           cout<<i.ff<<" "<<i.ss.ff<<" "<<i.ss.ss<<"\n";
       }
   }

}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }

	return 0;

}

ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define comp(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvli;
const int M = 1e9+7;
const int N = 1e6;
ll po(int,int);

void solve(){
   int n;cin>>n;
   int a[n];
   map<int,int> m;
   int mx = -1,el=-1;
   FOR(i,0,n){
       cin>>a[i];
       m[a[i]]++;
       if(m[a[i]]>mx){
           mx=m[a[i]];
           el = a[i];
       }
   }
   int l=-1,r=-1;
   FOR(i,0,n){
       if(a[i]==el){
           l=i;
           break;
       }
   }
   ROF(i,n-1,0){
       if(a[i]==el){
           r=i;
           break;
       }
   }
   if(n==1) cout<<0<<"\n";
   else{
       vector<pair<int,pair<int,int>>> p;
       ROF(i,l-1,0){
           int d = a[i]-a[i+1];
           if(d<0){
               p.pb({1,{i+1,i+2}});
           }
           else if(d>0){
               p.pb({2,{i+1,i+2}});
           }
       }
       FOR(i,r+1,n){
           int d = a[i]-a[i-1];
           if(d<0){
               p.pb({1,{i+1,i}});
           }
           else if(d>0){
               p.pb({2,{i+1,i}});
           }
       }
       cout<<p.size()<<"\n";
       for(auto i:p){
           cout<<i.ff<<" "<<i.ss.ff<<" "<<i.ss.ss<<"\n";
       }
   }

}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }

	return 0;

}

ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define vli vector<ll>
#define pb push_back
#define comp(v) v.begin(),v.end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
const int M = 1e9+7;
const int N = 2e5;
ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}
void solve(){
    int n;cin>>n;
    ll a[n];
    map<int,vector<int>> m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        m[a[i]].pb(i);
    }
    ll ans = 0 , el = -1 ;
     vector<pair<int,pair<int,int>>> v;
     for(auto i:m){
         if(i.ss.size()>ans){
             ans=i.ss.size();
             el = i.ff;
         }
     }
     bool vis[n]={0};
     for(int j=0;j<m[el].size();j++){
         vis[m[el][j]]=1;
         //cout<<m[el][j]<<" ";
         if(m[el][j]-1>=0 && !vis[m[el][j]-1]){
             if(a[m[el][j]-1] < el){
                 v.pb({1,{m[el][j],m[el][j]+1}});
                 m[el].pb(m[el][j]-1);
             }
             else if(a[m[el][j]-1] > el){
                 v.pb({2,{m[el][j],m[el][j]+1}});
                 m[el].pb(m[el][j]-1);
             }
             vis[m[el][j]-1]=1;
         }
         if(m[el][j]+1<=n-1 && !vis[m[el][j]+1]){
             if(a[m[el][j]+1] < el){
                 v.pb({1,{m[el][j]+2,m[el][j]+1}});
                 m[el].pb(m[el][j]+1);
             }
             else if(a[m[el][j]+1] > el){
                 v.pb({2,{m[el][j]+2,m[el][j]+1}});
                 m[el].pb(m[el][j]+1);
             }
             vis[m[el][j]+1]=1;
         }
     }
    for(auto i:m[el]) cout<<i<<" ";
     cout<<v.size()<<"\n";
     for(auto i:v){
         cout<<i.ff<<" ";
         cout<<i.ss.ff<<" "<<i.ss.ss<<"\n";
     }

}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
   // cin>>t;
    while(t--){
        solve();
    }

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define vli vector<ll>
#define pb push_back
#define comp(v) v.begin(),v.end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
const int M = 1e9+7;
const int N = 2e5;
ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}
void solve(){
    int n;cin>>n;
    ll a[n];
    map<int,vector<int>> m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        m[a[i]].pb(i);
    }
    ll ans = 0 , el = -1 ;
     vector<pair<int,pair<int,int>>> v;
     for(auto i:m){
         if(i.ss.size()>ans){
             ans=i.ss.size();
             el = i.ff;
         }
     }
     bool vis[n]={0};
     for(int j=0;j<m[el].size();j++){
         vis[m[el][j]]=1;
         //cout<<m[el][j]<<" ";
         if(m[el][j]-1>=0 && !vis[m[el][j]-1]){
             if(a[m[el][j]-1] < el){
                 v.pb({1,{m[el][j],m[el][j]+1}});
                 m[el].pb(m[el][j]-1);
             }
             else if(a[m[el][j]-1] > el){
                 v.pb({2,{m[el][j],m[el][j]+1}});
                 m[el].pb(m[el][j]-1);
             }
             vis[m[el][j]-1]=1;
         }
         if(m[el][j]+1<=n-1 && !vis[m[el][j]+1]){
             if(a[m[el][j]+1] < el){
                 v.pb({1,{m[el][j]+2,m[el][j]+1}});
                 m[el].pb(m[el][j]+1);
             }
             else if(a[m[el][j]+1] > el){
                 v.pb({2,{m[el][j]+2,m[el][j]+1}});
                 m[el].pb(m[el][j]+1);
             }
             vis[m[el][j]+1]=1;
         }
     }
   // for(auto i:m[el]) cout<<i<<" ";
     cout<<v.size()<<"\n";
     for(auto i:v){
         cout<<i.ff<<" ";
         cout<<i.ss.ff<<" "<<i.ss.ss<<"\n";
     }

}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
   // cin>>t;
    while(t--){
        solve();
    }

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define vli vector<ll>
#define pb push_back
#define comp(v) v.begin(),v.end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
const int M = 1e9+7;
const int N = 2e5;
ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}
void solve(){
    int n;cin>>n;
    ll a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    vector<pair<int,pair<int,int>>> v,p;
    for(int i=n-2;i>=0;i--){
        if(a[i]==a[i+1]) continue;
        ll d = abs(a[i]-a[i+1]);
        if(a[i]<a[i+1]){
            a[i] += d;
            v.pb({1,{i+1,i+2}});
        }
        else{
            a[i]-=d;
            v.pb({2,{i+1,i+2}});
        }
    }
    for(int i=1;i<n;i++){
        if(b[i]==b[i-1]) continue;
        ll d = abs(b[i]-b[i-1]);
        if(b[i]<b[i-1]){
            b[i] += d;
            p.pb({1,{i+1,i}});
        }
        else{
            b[i]-=d;
            p.pb({2,{i+1,i}});
        }
    }
    if(v.size()<p.size()){
    cout<<v.size()<<"\n";
    for(auto i:v){
        cout<<i.ff<<" ";
        cout<<i.ss.ff<<" "<<i.ss.ss<<"\n";
    }
    }
    else{
        cout<<p.size()<<"\n";
    for(auto i:p){
        cout<<i.ff<<" ";
        cout<<i.ss.ff<<" "<<i.ss.ss<<"\n";
    }
    }

}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
   // cin>>t;
    while(t--){
        solve();
    }

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define  loop(i,L,U)        for(long long int i=(long long int)L;i<U;i++)
#define  loopeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define  preflag               long long flag=0,i=0,j=0,k=0,l=0
#define  preflag2             long double flag=0,i=0,j=0,k=0,l=0
#define  mem(arr,x)         memset((arr), (x), sizeof((arr)));

#define  pb                          push_back
#define  ppb                        pop_back()
#define  pii                       pair<long long int , long long int >
#define  msi                       map< string,long long int>
#define  vi                           vector<long long int >
#define  iit                          iterator it,it1,it2
#define  iip                       iterator ip,ip1,ip2

#define  sz                         1000000
#define  check(x)             cout<<":::"<<x<<":::"<<endl
#define  dcheck(x,y)       cout<<":::"<<x<<":::"<<y<<endl
#define  i(c)                     cin>>c
#define  o(c)                     scanf("%lld",&c);
#define  mz(c,r)               long long r=c;while(c--)
#define  till(c)                 while(c--)
#define TEST_CASE(t)      for(ll int z=1;z<=t;z++)

#define  fs                       first
#define  sc                      second
#define  pi                         acos(-1.0)
#define  eps                     1e-9
#define  inf                     0x7fffffff

#define  gaira                 printf("::: pias necroxoda :::::::::::::  \n")
#define notrue                 false
#define ifnot                     else
#define eee                     cout<<'\n'
#define ll                        long long
#define    lfl                        long double
#define debug(x)           cout << '>' << #x << ':' << x << endl;
#define fast                    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x)                  x.begin(),x.end()
#define srt(v)                   sort(v.begin(),v.end())
#define  ret                     return

///*/////////////////// /// *
/*//    author-joydip007x  ///  *

///     Date<^>XX/08/2018    *///
ll x ,n ,pr,r=0,prnt=0,ans=0;
vector<ll> o,tmp;
set<ll>sss;
vector<string>vs;
ll index=0;
int main()
{
     fast;
     cin>>n; r=1;o.pb(0);
     for(ll i=1 ; i<=n ; i++)
     {
      cin>>x; o.pb(x);sss.insert(x);
     }
      for(ll i=1 ; i<=n ; i++)
     {
      x=o[i];
      if(i==1) { pr=x ; continue; }
      if( i>1 )
      {
            if( pr<x)
            {
                /// cout<<1<<" "<<i-1<<" "<<i<<endl;
                string sx="1 ",exta,extb;
                exta=to_string(i-1);
                extb=to_string(i);
                sx.insert( sx.end(),exta.begin() , exta.end() ); sx=sx+" ";
                sx.insert( sx.end(),extb.begin() , extb.end() );
                vs.pb(sx);
                prnt=1;
            }
            if( pr>x)
            {
               /// cout<<1<<" "<<i<<" "<<i-1<<endl;
                string sx="1 ",exta,extb;
                exta=to_string(i);
                extb=to_string(i-1);
                sx.insert( sx.end(),exta.begin() , exta.end() ); sx=sx+" ";
                sx.insert( sx.end(),extb.begin() , extb.end() );
                vs.pb(sx);
               prnt=1;
            }

      }
      pr=x;
     }
     if(!prnt) ret cout<<"0\n",0;
     reverse(vs.begin(),vs.end() );
     cout<<sss.size()-1<<endl;for(auto it:vs) cout<<it<<endl;
     ///for(ll i=0 ; i<r ; i++) cout<<s[i];

}


#include<bits/stdc++.h>
using namespace std;

#define  loop(i,L,U)        for(long long int i=(long long int)L;i<U;i++)
#define  loopeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define  preflag               long long flag=0,i=0,j=0,k=0,l=0
#define  preflag2             long double flag=0,i=0,j=0,k=0,l=0
#define  mem(arr,x)         memset((arr), (x), sizeof((arr)));

#define  pb                          push_back
#define  ppb                        pop_back()
#define  pii                       pair<long long int , long long int >
#define  msi                       map< string,long long int>
#define  vi                           vector<long long int >
#define  iit                          iterator it,it1,it2
#define  iip                       iterator ip,ip1,ip2

#define  sz                         1000000
#define  check(x)             cout<<":::"<<x<<":::"<<endl
#define  dcheck(x,y)       cout<<":::"<<x<<":::"<<y<<endl
#define  i(c)                     cin>>c
#define  o(c)                     scanf("%lld",&c);
#define  mz(c,r)               long long r=c;while(c--)
#define  till(c)                 while(c--)
#define TEST_CASE(t)      for(ll int z=1;z<=t;z++)

#define  fs                       first
#define  sc                      second
#define  pi                         acos(-1.0)
#define  eps                     1e-9
#define  inf                     0x7fffffff

#define  gaira                 printf("::: pias necroxoda :::::::::::::  \n")
#define notrue                 false
#define ifnot                     else
#define eee                     cout<<'\n'
#define ll                        long long
#define    lfl                        long double
#define debug(x)           cout << '>' << #x << ':' << x << endl;
#define fast                    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x)                  x.begin(),x.end()
#define srt(v)                   sort(v.begin(),v.end())
#define  ret                     return

///*/////////////////// /// *
/*//    author-joydip007x  ///  *

///     Date<^>XX/08/2018    *///
ll x ,n ,pr,r=0,prnt=0,ans=0;
vector<ll> o,tmp;
set<ll>sss;
vector<pair<string,ll> >vs;
vector<pair<string,ll> >::iterator it,tmpit;
ll index=0;
int main()
{
     fast;
     cin>>n; r=1;o.pb(0);
     for(ll i=1 ; i<=n ; i++)
     {
      cin>>x; o.pb(x);sss.insert(x);
     }
      for(ll i=1 ; i<=n ; i++)
     {
      x=o[i];
      if(i==1) { pr=x ; continue; }
      if( i>1 )
      {
            if( pr<x)
            {
                /// cout<<1<<" "<<i-1<<" "<<i<<endl;
                string sx="1 ",exta,extb;
                exta=to_string(i-1);
                extb=to_string(i);
                sx.insert( sx.end(),exta.begin() , exta.end() ); sx=sx+" ";
                sx.insert( sx.end(),extb.begin() , extb.end() );
                vs.pb({sx,0} ) ;
                prnt=1;
            }
            if( pr>x)
            {
               /// cout<<1<<" "<<i<<" "<<i-1<<endl;
                string sx="1 ",exta,extb;
                exta=to_string(i);
                extb=to_string(i-1);
                sx.insert( sx.end(),exta.begin() , exta.end() ); sx=sx+" ";
                sx.insert( sx.end(),extb.begin() , extb.end() );
                vs.pb({ sx,1 } );
               prnt=1;
            }

      }
      pr=x;
     }
     if(!prnt) ret cout<<"0\n",0;
     cout<<sss.size()-1<<endl;
     auto it2=vs.begin()  ;
     for(it=vs.begin() ; it!=vs.end() ; it++) {
       if( it->sc ) cout<<it->fs<<endl;
       else
       {
           it2=it;
         for(  ; it2!=vs.end() and it2->sc==0 ; it2++){  ;  }
         --it2;
         tmpit=it2;
         for( ; it2!=it ; it2-- ) cout<<it2->fs<<endl;
         cout<<it->fs<<endl;
        it=tmpit;
       }

     }
     ///for(ll i=0 ; i<r ; i++) cout<<s[i];

}


#include<bits/stdc++.h>
using namespace std;

#define  loop(i,L,U)        for(long long int i=(long long int)L;i<U;i++)
#define  loopeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define  preflag               long long flag=0,i=0,j=0,k=0,l=0
#define  preflag2             long double flag=0,i=0,j=0,k=0,l=0
#define  mem(arr,x)         memset((arr), (x), sizeof((arr)));

#define  pb                          push_back
#define  ppb                        pop_back()
#define  pii                       pair<long long int , long long int >
#define  msi                       map< string,long long int>
#define  vi                           vector<long long int >
#define  iit                          iterator it,it1,it2
#define  iip                       iterator ip,ip1,ip2

#define  sz                         1000000
#define  check(x)             cout<<":::"<<x<<":::"<<endl
#define  dcheck(x,y)       cout<<":::"<<x<<":::"<<y<<endl
#define  i(c)                     cin>>c
#define  o(c)                     scanf("%lld",&c);
#define  mz(c,r)               long long r=c;while(c--)
#define  till(c)                 while(c--)
#define TEST_CASE(t)      for(ll int z=1;z<=t;z++)

#define  fs                       first
#define  sc                      second
#define  pi                         acos(-1.0)
#define  eps                     1e-9
#define  inf                     0x7fffffff

#define  gaira                 printf("::: pias necroxoda :::::::::::::  \n")
#define notrue                 false
#define ifnot                     else
#define eee                     cout<<'\n'
#define ll                        long long
#define    lfl                        long double
#define debug(x)           cout << '>' << #x << ':' << x << endl;
#define fast                    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x)                  x.begin(),x.end()
#define srt(v)                   sort(v.begin(),v.end())
#define  ret                     return

///*/////////////////// /// *
/*//    author-joydip007x  ///  *

///     Date<^>XX/08/2018    *///
ll x ,n ,pr,r=0,prnt=0,ans=0;
vector<ll> o,tmp;
set<ll>ss;
vector<string>vs;
ll index=0;
int main()
{
     fast;
     cin>>n; r=1;
     for(ll i=1 ; i<=n ; i++)
     {
      cin>>x; o.pb(x);
      if(i==1) { pr=x ; continue; }
      if( i>1 )
      {
            if( pr<x)
            {
                ans++;
                /// cout<<1<<" "<<i-1<<" "<<i<<endl;
                string sx="1 ";
                sx.pb(i-1+'0');sx+=" ";
                sx.pb(i+'0');
                vs.pb(sx);
                prnt=1;
            }
            if( pr>x)
            {
                ans++;
                /// cout<<1<<" "<<i<<" "<<i-1<<endl;
                string sx="1 ";
                sx.pb(i-1+'0');sx+=" ";
                sx.pb(i+'0');
                vs.pb(sx);
                prnt=1 ;
            }

      }
      pr=x;
     }
     if(!prnt) ret cout<<"0\n",0;
     cout<<ans<<endl;for(auto it:vs) cout<<it<<endl;
     ///for(ll i=0 ; i<r ; i++) cout<<s[i];

}


#include<bits/stdc++.h>
using namespace std;

#define  loop(i,L,U)        for(long long int i=(long long int)L;i<U;i++)
#define  loopeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define  preflag               long long flag=0,i=0,j=0,k=0,l=0
#define  preflag2             long double flag=0,i=0,j=0,k=0,l=0
#define  mem(arr,x)         memset((arr), (x), sizeof((arr)));

#define  pb                          push_back
#define  ppb                        pop_back()
#define  pii                       pair<long long int , long long int >
#define  msi                       map< string,long long int>
#define  vi                           vector<long long int >
#define  iit                          iterator it,it1,it2
#define  iip                       iterator ip,ip1,ip2

#define  sz                         1000000
#define  check(x)             cout<<":::"<<x<<":::"<<endl
#define  dcheck(x,y)       cout<<":::"<<x<<":::"<<y<<endl
#define  i(c)                     cin>>c
#define  o(c)                     scanf("%lld",&c);
#define  mz(c,r)               long long r=c;while(c--)
#define  till(c)                 while(c--)
#define TEST_CASE(t)      for(ll int z=1;z<=t;z++)

#define  fs                       first
#define  sc                      second
#define  pi                         acos(-1.0)
#define  eps                     1e-9
#define  inf                     0x7fffffff

#define  gaira                 printf("::: pias necroxoda :::::::::::::  \n")
#define notrue                 false
#define ifnot                     else
#define eee                     cout<<'\n'
#define ll                        long long
#define    lfl                        long double
#define debug(x)           cout << '>' << #x << ':' << x << endl;
#define fast                    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x)                  x.begin(),x.end()
#define srt(v)                   sort(v.begin(),v.end())
#define  ret                     return

///*/////////////////// /// *
/*//    author-joydip007x  ///  *

///     Date<^>XX/08/2018    *///
ll n,tmpx,index,x;
vector<ll>v;
map<ll,ll>m;
int main()
{
    fast;
    cin>>n;
    v.pb(-1);
    tmpx=-1;
    for(int i=1; i<=n; i++)
    {
        cin>>x;
        v.pb(x);
        ++m[x];
        if(tmpx<m[x]) {
        index=i;
        tmpx=m[x];
        }
    }
    if(n==1) ret cout<<"0",0;
    cout<<n-m[ v[index] ]<<endl;
    if (n-m[ v[index] ]==0) return 0;
    for(ll i=index-1 ; i ; i--){

        if( v[i]>v[i+1] ) cout<<"2 "<<i<<" "<<i+1<<endl;
        if(v[i]<v[i+1]  ) cout<<"1 "<<i<<" "<<i+1<<endl;
        v[i]=v[index];
    }
    for(ll i=index+1 ; i<=n ; i++){

        if( v[i]>v[i-1] ) cout<<"2 "<<i<<" "<<i-1<<endl;
        if(v[i]<v[i-1]  ) cout<<"1 "<<i<<" "<<i-1<<endl;
        v[i]=v[index];
    }
}


#include<bits/stdc++.h>
using namespace std;

#define  loop(i,L,U)        for(long long int i=(long long int)L;i<U;i++)
#define  loopeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define  preflag               long long flag=0,i=0,j=0,k=0,l=0
#define  preflag2             long double flag=0,i=0,j=0,k=0,l=0
#define  mem(arr,x)         memset((arr), (x), sizeof((arr)));

#define  pb                          push_back
#define  ppb                        pop_back()
#define  pii                       pair<long long int , long long int >
#define  msi                       map< string,long long int>
#define  vi                           vector<long long int >
#define  iit                          iterator it,it1,it2
#define  iip                       iterator ip,ip1,ip2

#define  sz                         1000000
#define  check(x)             cout<<":::"<<x<<":::"<<endl
#define  dcheck(x,y)       cout<<":::"<<x<<":::"<<y<<endl
#define  i(c)                     cin>>c
#define  o(c)                     scanf("%lld",&c);
#define  mz(c,r)               long long r=c;while(c--)
#define  till(c)                 while(c--)
#define TEST_CASE(t)      for(ll int z=1;z<=t;z++)

#define  fs                       first
#define  sc                      second
#define  pi                         acos(-1.0)
#define  eps                     1e-9
#define  inf                     0x7fffffff

#define  gaira                 printf("::: pias necroxoda :::::::::::::  \n")
#define notrue                 false
#define ifnot                     else
#define eee                     cout<<'\n'
#define ll                        long long
#define    lfl                        long double
#define debug(x)           cout << '>' << #x << ':' << x << endl;
#define fast                    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x)                  x.begin(),x.end()
#define srt(v)                   sort(v.begin(),v.end())
#define  ret                     return

///*/////////////////// /// *
/*//    author-joydip007x  ///  *

///     Date<^>XX/08/2018    *///
ll x ,n ,pr,r=0,prnt=0,ans=0;
vector<ll> o,tmp;
set<ll>ss;
vector<string>vs;
ll index=0;
int main()
{
     fast;
     cin>>n; r=1;
     for(ll i=1 ; i<=n ; i++)
     {
      cin>>x; o.pb(x);
      if(i==1) { pr=x ; continue; }
      if( i>1 )
      {
            if( pr<x)
            {
                ans++;
                /// cout<<1<<" "<<i-1<<" "<<i<<endl;
                string sx="1 ";
                sx.pb(i-1+'0');sx+=" ";
                sx.pb(i+'0');
                vs.pb(sx);
                prnt=1;
            }
            if( pr>x)
            {
                ans++;
                /// cout<<1<<" "<<i<<" "<<i-1<<endl;
                string sx="1 ";
                sx.pb(i-1+'0');sx+=" ";
                sx.pb(i+'0');
                vs.pb(sx);
                prnt=1 ;
            }

      }
      pr=x;
     }
     if(!prnt) ret cout<<"0\n",0;
     reverse(vs.begin(),vs.end() );
     cout<<ans<<endl;for(auto it:vs) cout<<it<<endl;
     ///for(ll i=0 ; i<r ; i++) cout<<s[i];

}


#include<bits/stdc++.h>
using namespace std;

#define  loop(i,L,U)        for(long long int i=(long long int)L;i<U;i++)
#define  loopeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define  preflag               long long flag=0,i=0,j=0,k=0,l=0
#define  preflag2             long double flag=0,i=0,j=0,k=0,l=0
#define  mem(arr,x)         memset((arr), (x), sizeof((arr)));

#define  pb                          push_back
#define  ppb                        pop_back()
#define  pii                       pair<long long int , long long int >
#define  msi                       map< string,long long int>
#define  vi                           vector<long long int >
#define  iit                          iterator it,it1,it2
#define  iip                       iterator ip,ip1,ip2

#define  sz                         1000000
#define  check(x)             cout<<":::"<<x<<":::"<<endl
#define  dcheck(x,y)       cout<<":::"<<x<<":::"<<y<<endl
#define  i(c)                     cin>>c
#define  o(c)                     scanf("%lld",&c);
#define  mz(c,r)               long long r=c;while(c--)
#define  till(c)                 while(c--)
#define TEST_CASE(t)      for(ll int z=1;z<=t;z++)

#define  fs                       first
#define  sc                      second
#define  pi                         acos(-1.0)
#define  eps                     1e-9
#define  inf                     0x7fffffff

#define  gaira                 printf("::: pias necroxoda :::::::::::::  \n")
#define notrue                 false
#define ifnot                     else
#define eee                     cout<<'\n'
#define ll                        long long
#define    lfl                        long double
#define debug(x)           cout << '>' << #x << ':' << x << endl;
#define fast                    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x)                  x.begin(),x.end()
#define srt(v)                   sort(v.begin(),v.end())
#define  ret                     return

///*/////////////////// /// *
/*//    author-joydip007x  ///  *

///     Date<^>XX/08/2018    *///
ll x ,n ,pr,r=0,prnt=0,ans=0;
vector<ll> o,tmp;
set<ll>sss;
vector<string>vs;
ll index=0;
int main()
{
     fast;
     cin>>n; r=1;o.pb(0);
     for(ll i=1 ; i<=n ; i++)
     {
      cin>>x; o.pb(x);sss.insert(x);
     }
      for(ll i=1 ; i<=n ; i++)
     {
      x=o[i];
      if(i==1) { pr=x ; continue; }
      if( i>1 )
      {
            if( pr<x)
            {
                /// cout<<1<<" "<<i-1<<" "<<i<<endl;
                string sx="1 ",exta,extb;
                exta=to_string(i-1);
                extb=to_string(i);
                sx.insert( sx.end(),exta.begin() , exta.end() ); sx=sx+" ";
                sx.insert( sx.end(),extb.begin() , extb.end() );
                vs.pb(sx);
                prnt=1;
            }
            if( pr>x)
            {
               /// cout<<1<<" "<<i<<" "<<i-1<<endl;
                string sx="1 ",exta,extb;
                exta=to_string(i);
                extb=to_string(i-1);
                sx.insert( sx.end(),exta.begin() , exta.end() ); sx=sx+" ";
                sx.insert( sx.end(),extb.begin() , extb.end() );
                vs.pb(sx);
               prnt=1;
            }

      }
      pr=x;
     }
     if(!prnt) ret cout<<"0\n",0;
     reverse(vs.begin(),vs.end() )
     cout<<sss.size()-1<<endl;for(auto it:vs) cout<<it<<endl;
     ///for(ll i=0 ; i<r ; i++) cout<<s[i];

}


#include<bits/stdc++.h>
using namespace std;

#define  loop(i,L,U)        for(long long int i=(long long int)L;i<U;i++)
#define  loopeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define  preflag               long long flag=0,i=0,j=0,k=0,l=0
#define  preflag2             long double flag=0,i=0,j=0,k=0,l=0
#define  mem(arr,x)         memset((arr), (x), sizeof((arr)));

#define  pb                          push_back
#define  ppb                        pop_back()
#define  pii                       pair<long long int , long long int >
#define  msi                       map< string,long long int>
#define  vi                           vector<long long int >
#define  iit                          iterator it,it1,it2
#define  iip                       iterator ip,ip1,ip2

#define  sz                         1000000
#define  check(x)             cout<<":::"<<x<<":::"<<endl
#define  dcheck(x,y)       cout<<":::"<<x<<":::"<<y<<endl
#define  i(c)                     cin>>c
#define  o(c)                     scanf("%lld",&c);
#define  mz(c,r)               long long r=c;while(c--)
#define  till(c)                 while(c--)
#define TEST_CASE(t)      for(ll int z=1;z<=t;z++)

#define  fs                       first
#define  sc                      second
#define  pi                         acos(-1.0)
#define  eps                     1e-9
#define  inf                     0x7fffffff

#define  gaira                 printf("::: pias necroxoda :::::::::::::  \n")
#define notrue                 false
#define ifnot                     else
#define eee                     cout<<'\n'
#define ll                        long long
#define    lfl                        long double
#define debug(x)           cout << '>' << #x << ':' << x << endl;
#define fast                    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x)                  x.begin(),x.end()
#define srt(v)                   sort(v.begin(),v.end())
#define  ret                     return

///*/////////////////// /// *
/*//    author-joydip007x  ///  *

///     Date<^>XX/08/2018    *///
ll n,tmpx,index,x;
vector<ll>v;
map<ll,ll>m;
int main()
{
    cin>>n;
    v.pb(-1);
    tmpx=-1;
    for(int i=1; i<=n; i++)
    {
        cin>>x;
        v.pb(x);
        ++m[x];
        if(tmpx<m[x]) {
        index=i;
        tmpx=m[x];
        }
    }
    if(n==1) ret cout<<"0",0;
    cout<<n-m[ v[index] ]<<endl;
    if (n-m[ v[index] ]==0) return 0;
    for(ll i=index-1 ; i ; i--){

        if( v[i]>v[i+1] ) cout<<"2 "<<i<<" "<<i+1<<endl;
        if(v[i]<v[i+1]  ) cout<<"1 "<<i<<" "<<i+1<<endl;
        v[i]=v[index];
    }
    for(ll i=index+1 ; i<=n ; i++){

        if( v[i]>v[i-1] ) cout<<"2 "<<i<<" "<<i-1<<endl;
        if(v[i]<v[i-1]  ) cout<<"1 "<<i<<" "<<i-1<<endl;
        v[i]=v[index];
    }

}


#include<bits/stdc++.h>
using namespace std;

#define  loop(i,L,U)        for(long long int i=(long long int)L;i<U;i++)
#define  loopeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define  preflag               long long flag=0,i=0,j=0,k=0,l=0
#define  preflag2             long double flag=0,i=0,j=0,k=0,l=0
#define  mem(arr,x)         memset((arr), (x), sizeof((arr)));

#define  pb                          push_back
#define  ppb                        pop_back()
#define  pii                       pair<long long int , long long int >
#define  msi                       map< string,long long int>
#define  vi                           vector<long long int >
#define  iit                          iterator it,it1,it2
#define  iip                       iterator ip,ip1,ip2

#define  sz                         1000000
#define  check(x)             cout<<":::"<<x<<":::"<<endl
#define  dcheck(x,y)       cout<<":::"<<x<<":::"<<y<<endl
#define  i(c)                     cin>>c
#define  o(c)                     scanf("%lld",&c);
#define  mz(c,r)               long long r=c;while(c--)
#define  till(c)                 while(c--)
#define TEST_CASE(t)      for(ll int z=1;z<=t;z++)

#define  fs                       first
#define  sc                      second
#define  pi                         acos(-1.0)
#define  eps                     1e-9
#define  inf                     0x7fffffff

#define  gaira                 printf("::: pias necroxoda :::::::::::::  \n")
#define notrue                 false
#define ifnot                     else
#define eee                     cout<<'\n'
#define ll                        long long
#define    lfl                        long double
#define debug(x)           cout << '>' << #x << ':' << x << endl;
#define fast                    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x)                  x.begin(),x.end()
#define srt(v)                   sort(v.begin(),v.end())
#define  ret                     return

///*/////////////////// /// *
/*//    author-joydip007x  ///  *

///     Date<^>XX/08/2018    *///
ll x ,n ,pr,r=0,prnt=0,ans=0;
vector<ll> o,tmp;
set<ll>sss;
vector<pair<string,ll> >vs;
vector<pair<string,ll> >::iterator it,tmpit;
ll index=0;
int main()
{
     fast;
     cin>>n; r=1;o.pb(0);
     for(ll i=1 ; i<=n ; i++)
     {
      cin>>x; o.pb(x);sss.insert(x);
     }
      for(ll i=1 ; i<=n ; i++)
     {
      x=o[i];
      if(i==1) { pr=x ; continue; }
      if( i>1 )
      {
            if( pr<x)
            {
                /// cout<<1<<" "<<i-1<<" "<<i<<endl;
                string sx="1 ",exta,extb;
                exta=to_string(i-1);
                extb=to_string(i);
                sx.insert( sx.end(),exta.begin() , exta.end() ); sx=sx+" ";
                sx.insert( sx.end(),extb.begin() , extb.end() );
                vs.pb({sx,0} ) ;
                prnt=1;
            }
            if( pr>x)
            {
               /// cout<<1<<" "<<i<<" "<<i-1<<endl;
                string sx="1 ",exta,extb;
                exta=to_string(i);
                extb=to_string(i-1);
                sx.insert( sx.end(),exta.begin() , exta.end() ); sx=sx+" ";
                sx.insert( sx.end(),extb.begin() , extb.end() );
                vs.pb({ sx,1 } );
               prnt=1;
            }

      }
      pr=x;
     }
     if(!prnt) ret cout<<"0\n",0;
     cout<<sss.size()-1<<endl;
     auto it2=vs.begin()  ;
     for(it=vs.begin() ; it!=vs.end() ; it++) {
       if( it->sc ) cout<<it->fs<<endl;
       else
       {
           it2=it+1;
         for(  ; it2!=vs.end() and it2->sc==0 ; it2++){  ;  }
         --it2;
         tmpit=it2;
         for( ; it2!=it ; it2-- ) cout<<it2->fs<<endl;
         cout<<it->fs<<endl;
        it=tmpit;
       }

     }
     ///for(ll i=0 ; i<r ; i++) cout<<s[i];

}


#include<bits/stdc++.h>
using namespace std;

#define  loop(i,L,U)        for(long long int i=(long long int)L;i<U;i++)
#define  loopeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define  preflag               long long flag=0,i=0,j=0,k=0,l=0
#define  preflag2             long double flag=0,i=0,j=0,k=0,l=0
#define  mem(arr,x)         memset((arr), (x), sizeof((arr)));

#define  pb                          push_back
#define  ppb                        pop_back()
#define  pii                       pair<long long int , long long int >
#define  msi                       map< string,long long int>
#define  vi                           vector<long long int >
#define  iit                          iterator it,it1,it2
#define  iip                       iterator ip,ip1,ip2

#define  sz                         1000000
#define  check(x)             cout<<":::"<<x<<":::"<<endl
#define  dcheck(x,y)       cout<<":::"<<x<<":::"<<y<<endl
#define  i(c)                     cin>>c
#define  o(c)                     scanf("%lld",&c);
#define  mz(c,r)               long long r=c;while(c--)
#define  till(c)                 while(c--)
#define TEST_CASE(t)      for(ll int z=1;z<=t;z++)

#define  fs                       first
#define  sc                      second
#define  pi                         acos(-1.0)
#define  eps                     1e-9
#define  inf                     0x7fffffff

#define  gaira                 printf("::: pias necroxoda :::::::::::::  \n")
#define notrue                 false
#define ifnot                     else
#define eee                     cout<<'\n'
#define ll                        long long
#define    lfl                        long double
#define debug(x)           cout << '>' << #x << ':' << x << endl;
#define fast                    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x)                  x.begin(),x.end()
#define srt(v)                   sort(v.begin(),v.end())
#define  ret                     return

///*/////////////////// /// *
/*//    author-joydip007x  ///  *

///     Date<^>XX/08/2018    *///
ll n,tmpx,index,x;
vector<ll>v;
map<ll,ll>m;
int main()
{
    cin>>n;
    v.pb(-1);
    tmpx=INT_MIN;
    for(int i=1; i<=n; i++)
    {
        cin>>x;
        v.pb(x);
        m[x]++;
        if(tmpx<m[x]) {
        index=i;
        }
    }
    if(n==1) ret cout<<"0",0;
    cout<<n-m[ v[index] ]<<endl;
    if (n-m[ v[index] ]==0) return 0;
    for(ll i=index-1 ; i ; i--){

        if( v[i]>v[i+1] ) cout<<"2 "<<i<<" "<<i+1<<endl;
        if(v[i]<v[i+1]  ) cout<<"1 "<<i<<" "<<i+1<<endl;
        v[i]=v[index];
    }
    for(ll i=index+1 ; i<=n ; i++){

        if( v[i]>v[i-1] ) cout<<"2 "<<i<<" "<<i-1<<endl;
        if(v[i]<v[i-1]  ) cout<<"1 "<<i<<" "<<i-1<<endl;
        v[i]=v[index];
    }

}


#include<bits/stdc++.h>
using namespace std;

#define  loop(i,L,U)        for(long long int i=(long long int)L;i<U;i++)
#define  loopeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define  preflag               long long flag=0,i=0,j=0,k=0,l=0
#define  preflag2             long double flag=0,i=0,j=0,k=0,l=0
#define  mem(arr,x)         memset((arr), (x), sizeof((arr)));

#define  pb                          push_back
#define  ppb                        pop_back()
#define  pii                       pair<long long int , long long int >
#define  msi                       map< string,long long int>
#define  vi                           vector<long long int >
#define  iit                          iterator it,it1,it2
#define  iip                       iterator ip,ip1,ip2

#define  sz                         1000000
#define  check(x)             cout<<":::"<<x<<":::"<<endl
#define  dcheck(x,y)       cout<<":::"<<x<<":::"<<y<<endl
#define  i(c)                     cin>>c
#define  o(c)                     scanf("%lld",&c);
#define  mz(c,r)               long long r=c;while(c--)
#define  till(c)                 while(c--)
#define TEST_CASE(t)      for(ll int z=1;z<=t;z++)

#define  fs                       first
#define  sc                      second
#define  pi                         acos(-1.0)
#define  eps                     1e-9
#define  inf                     0x7fffffff

#define  gaira                 printf("::: pias necroxoda :::::::::::::  \n")
#define notrue                 false
#define ifnot                     else
#define eee                     cout<<'\n'
#define ll                        long long
#define    lfl                        long double
#define debug(x)           cout << '>' << #x << ':' << x << endl;
#define fast                    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x)                  x.begin(),x.end()
#define srt(v)                   sort(v.begin(),v.end())
#define  ret                     return

///*/////////////////// /// *
/*//    author-joydip007x  ///  *

///     Date<^>XX/08/2018    *///
ll n,tmpx,index,x;
vector<ll>v;
map<ll,ll>m;
int main()
{
    cin>>n;
    v.pb(-1);
    tmpx=INT_MIN;
    for(int i=1; i<=n; i++)
    {
        cin>>x;
        v.pb(x);
        m[x]++;
        if(tmpx<m[x]) {
        index=i;
        }
    }
    if(n==1) ret cout<<"0",0;
    cout<<n-m[ v[index] ]<<endl;
    if (n-m[ v[index] ]==0) return 0;
    for(ll i=index-1 ; i ; i--){

        if( v[i]>v[i+1] ) cout<<"2 "<<i<<" "<<i+1<<endl;
        if(v[i]<v[i+1]  ) cout<<"1 "<<i<<" "<<i+1<<endl;
    }
    for(ll i=index+1 ; i<=n ; i++){

        if( v[i]>v[i-1] ) cout<<"2 "<<i<<" "<<i-1<<endl;
        if(v[i]<v[i-1]  ) cout<<"1 "<<i<<" "<<i-1<<endl;
    }

}


    #include <bits/stdc++.h>
    #define endl "\n"
    #define ll long long
    #define all(v) ((v).begin()), ((v).end())
    #define sz(v) ((int)((v).size()))
    #define clr(v, d) memset(v, d, sizeof(v))
    #define rep(i, v) for (int i = 0; i < sz(v); ++i)
    #define lp(i, n) for (int i = 0; i < (int)(n); ++i)
    #define lpi(i, j, n) for (int i = (j); i < (int)(n); ++i)
    #define lpd(i, j, n) for (int i = (j); i >= (int)(n); --i)
    #define vi vector<int>
    #define vl vector<ll>
    #define ii pair<ll, ll>
    #define vii vector<ii>
    #define PIii double PPPPPP = 3.14159265358979323846;
    #define pb push_back
    using namespace std;
    const int N = 2e5 + 5;
    int vis[N];
    void run() {
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr), cout.tie(nullptr);
    }
    int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
        run();
        int tt=1;
       // cin>>tt;
        while(tt--)
        {
            int n;
            cin>>n;
            vi v(n);
            for(int&i:v)cin>>i;
            reverse(all(v));
            for(int i=0;i+1<n;i++)
            {
                    if(v[i]>v[i+1]) {
                        cout << 2 <<' '<< n - i - 1 << ' ' << n - i << endl;
                        v[i+1]=v[i];
                    }
                    if(v[i]<v[i+1]) {
                        cout << 1 << ' '<<n - i - 1 << ' ' << n - i << endl;
                        v[i + 1] = v[i];
                    }
            }
        }

        return 0;
    }


    #include <bits/stdc++.h>
    #define endl "\n"
    #define ll long long
    #define all(v) ((v).begin()), ((v).end())
    #define sz(v) ((int)((v).size()))
    #define clr(v, d) memset(v, d, sizeof(v))
    #define rep(i, v) for (int i = 0; i < sz(v); ++i)
    #define lp(i, n) for (int i = 0; i < (int)(n); ++i)
    #define lpi(i, j, n) for (int i = (j); i < (int)(n); ++i)
    #define lpd(i, j, n) for (int i = (j); i >= (int)(n); --i)
    #define vi vector<int>
    #define vl vector<ll>
    #define ii pair<ll, ll>
    #define vii vector<ii>
    #define PIii double PPPPPP = 3.14159265358979323846;
    #define pb push_back
    using namespace std;
    const int N = 2e5 + 5;
    int pos[N];
    map<ll,ll> freq;
    void run() {
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr), cout.tie(nullptr);
    }
    int main() {
#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
#endif
        run();
        int tt = 1;
        // cin>>tt;
        while (tt--) {
            ll n, ans = 0, mx = -1e9;
            cin >> n;
            vl v(n);
            for (ll &i:v) {
                cin >> i;
                freq[i]++;
                mx = max(mx, freq[i]);
            }
            ll boss;
            for (ll&i:v) {
                if (freq[i] == mx)
                    boss = i;
            }
            for (ll &i:v)
                ans += i != boss;
            cout << ans << endl;
            for (int i = 0; i < n; i++) {
                if (v[i] == boss) {
                    for (int j = 0; j < i; ++j) {
                        if (v[j] > boss)
                            cout << 2 << ' ' << j + 1 << ' ' << j + 2 << endl;
                        if (v[j] < boss)
                            cout << 1 << ' ' << j+ 1 << ' ' << j + 2 << endl;
                    }
                    for (int j = i + 1; j < n; ++j) {
                        if (v[j] > boss)
                            cout << 2 << ' ' << j + 1 << ' ' << j + 2 << endl;
                        if (v[j] < boss)
                            cout << 1 << ' ' << j + 1 << ' ' << j + 2 << endl;
                    }
                    return 0;
                }
            }

            return 0;
        }
    }


    #include <bits/stdc++.h>
    #define endl "\n"
    #define ll long long
    #define all(v) ((v).begin()), ((v).end())
    #define sz(v) ((int)((v).size()))
    #define clr(v, d) memset(v, d, sizeof(v))
    #define rep(i, v) for (int i = 0; i < sz(v); ++i)
    #define lp(i, n) for (int i = 0; i < (int)(n); ++i)
    #define lpi(i, j, n) for (int i = (j); i < (int)(n); ++i)
    #define lpd(i, j, n) for (int i = (j); i >= (int)(n); --i)
    #define vi vector<int>
    #define vl vector<ll>
    #define ii pair<ll, ll>
    #define vii vector<ii>
    #define PIii double PPPPPP = 3.14159265358979323846;
    #define pb push_back
    using namespace std;
    const int N = 2e5 + 5;
    int pos[N];
    map<ll,ll> freq;
    void run() {
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr), cout.tie(nullptr);
    }
    int main() {
#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
#endif
        run();
        int tt = 1;
        // cin>>tt;
        while (tt--) {
            ll n, ans = 0, mx = -1e9;
            cin >> n;
            vl v(n);
            for (ll &i:v) {
                cin >> i;
                freq[i]++;
                mx = max(mx, freq[i]);
            }
            ll boss;
            for (ll&i:v) {
                if (freq[i] == mx)
                    boss = i;
            }
            for (ll &i:v)
                ans += i != boss;
            cout << ans << endl;
            for (int i = 0; i < n; i++) {
                if (v[i] == boss) {
                    for (int j = i-1; j > -1; --j) {
                        if (v[j] > boss)
                            cout << 2 << ' ' << j + 1 << ' ' << j + 2 << endl;
                        if (v[j] < boss)
                            cout << 1 << ' ' << j+ 1 << ' ' << j + 2 << endl;
                    }
                    for (int j = i + 1; j < n; ++j) {
                        if (v[j] > boss)
                            cout << 2 << ' ' << j+1 << ' ' << j << endl;
                        if (v[j] < boss)
                            cout << 1 << ' ' << j+1  << ' ' << j << endl;
                    }
                    return 0;
                }
            }

            return 0;
        }
    }


    #include <bits/stdc++.h>
    #define endl "\n"
    #define ll long long
    #define all(v) ((v).begin()), ((v).end())
    #define sz(v) ((int)((v).size()))
    #define clr(v, d) memset(v, d, sizeof(v))
    #define rep(i, v) for (int i = 0; i < sz(v); ++i)
    #define lp(i, n) for (int i = 0; i < (int)(n); ++i)
    #define lpi(i, j, n) for (int i = (j); i < (int)(n); ++i)
    #define lpd(i, j, n) for (int i = (j); i >= (int)(n); --i)
    #define vi vector<int>
    #define vl vector<ll>
    #define ii pair<ll, ll>
    #define vii vector<ii>
    #define PIii double PPPPPP = 3.14159265358979323846;
    #define pb push_back
    using namespace std;
    const int N = 2e5 + 5;
    int pos[N];
    map<ll,ll> freq;
    void run() {
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr), cout.tie(nullptr);
    }
    int main() {
#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
#endif
        run();
        int tt = 1;
        // cin>>tt;
        while (tt--) {
            ll n, ans = 0, mx = -1e9;
            cin >> n;
            vl v(n);
            for (ll &i:v) {
                cin >> i;
                freq[i]++;
                mx = max(mx, freq[i]);
            }
            ll boss;
            for (ll&i:v) {
                if (freq[i] == mx)
                    boss = i;
            }
            for (ll &i:v)
                ans += i != boss;
            cout << ans << endl;
            for (int i = 0; i < n; i++) {
                if (v[i] == boss) {
                    for (int j = i-1; j > -1; --j) {
                        if (v[j] > boss)
                            cout << 2 << ' ' << j + 1 << ' ' << j + 2 << endl;
                        if (v[j] < boss)
                            cout << 1 << ' ' << j+ 1 << ' ' << j + 2 << endl;
                    }
                    for (int j = i + 1; j < n; ++j) {
                        if (v[j] > boss)
                            cout << 2 << ' ' << j + 1 << ' ' << j + 2 << endl;
                        if (v[j] < boss)
                            cout << 1 << ' ' << j + 1 << ' ' << j + 2 << endl;
                    }
                    return 0;
                }
            }

            return 0;
        }
    }


    #include <bits/stdc++.h>
    #define endl "\n"
    #define ll long long
    #define all(v) ((v).begin()), ((v).end())
    #define sz(v) ((int)((v).size()))
    #define clr(v, d) memset(v, d, sizeof(v))
    #define rep(i, v) for (int i = 0; i < sz(v); ++i)
    #define lp(i, n) for (int i = 0; i < (int)(n); ++i)
    #define lpi(i, j, n) for (int i = (j); i < (int)(n); ++i)
    #define lpd(i, j, n) for (int i = (j); i >= (int)(n); --i)
    #define vi vector<int>
    #define vl vector<ll>
    #define ii pair<ll, ll>
    #define vii vector<ii>
    #define PIii double PPPPPP = 3.14159265358979323846;
    #define pb push_back
    using namespace std;
    const int N = 2e5 + 5;
    int pos[N];
    map<ll,ll> freq;
    void run() {
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr), cout.tie(nullptr);
    }
    int main() {
#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
#endif
        run();
        int tt = 1;
        // cin>>tt;
        while (tt--) {
            ll n, ans = 0, mx = -1e9;
            cin >> n;
            vl v(n);
            for (ll &i:v) {
                cin >> i;
                freq[i]++;
                mx = max(mx, freq[i]);
            }
            ll boss;
            for (ll&i:v) {
                if (freq[i] == mx)
                    boss = i;
            }
            for (ll &i:v)
                ans += i != boss;
            cout << ans << endl;
            for (int i = 0; i < n; i++) {
                if (v[i] == boss) {
                    for (int j = i-1; j > -1; --j) {
                        if (v[j] > boss)
                            cout << 2 << ' ' << j + 1 << ' ' << j + 2 << endl;
                        if (v[j] < boss)
                            cout << 1 << ' ' << j+ 1 << ' ' << j + 2 << endl;
                    }
                    for (int j = i + 1; j < n; ++j) {
                        if (v[j] > boss)
                            cout << 2 << ' ' << j << ' ' << j -1 << endl;
                        if (v[j] < boss)
                            cout << 1 << ' ' << j  << ' ' << j -1 << endl;
                    }
                    return 0;
                }
            }

            return 0;
        }
    }


    #include <bits/stdc++.h>
    #define endl "\n"
    #define ll long long
    #define all(v) ((v).begin()), ((v).end())
    #define sz(v) ((int)((v).size()))
    #define clr(v, d) memset(v, d, sizeof(v))
    #define rep(i, v) for (int i = 0; i < sz(v); ++i)
    #define lp(i, n) for (int i = 0; i < (int)(n); ++i)
    #define lpi(i, j, n) for (int i = (j); i < (int)(n); ++i)
    #define lpd(i, j, n) for (int i = (j); i >= (int)(n); --i)
    #define vi vector<int>
    #define vl vector<ll>
    #define ii pair<ll, ll>
    #define vii vector<ii>
    #define PIii double PPPPPP = 3.14159265358979323846;
    #define pb push_back
    using namespace std;
    const int N = 2e5 + 5;
    int vis[N];
    void run() {
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr), cout.tie(nullptr);
    }
    int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
        run();
        int tt=1;
       // cin>>tt;
        while(tt--)
        {
            int n,ans=0;
            cin>>n;
            vi v(n);
            for(int&i:v)cin>>i;
            for(int&i:v)
                ans+=i!=v.back();
            cout<<ans<<endl;
            reverse(all(v));
            for(int i=0;i+1<n;i++)
            {
                    if(v[i]>v[i+1]) {
                        cout << 1 <<' '<< n - i - 1 << ' ' << n - i << endl;
                        v[i+1]=v[i];
                    }
                    if(v[i]<v[i+1]) {
                        cout << 2 << ' '<<n - i - 1 << ' ' << n - i << endl;
                        v[i + 1] = v[i];
                    }
            }
        }

        return 0;
    }


    #include <bits/stdc++.h>
    #define endl "\n"
    #define ll long long
    #define all(v) ((v).begin()), ((v).end())
    #define sz(v) ((int)((v).size()))
    #define clr(v, d) memset(v, d, sizeof(v))
    #define rep(i, v) for (int i = 0; i < sz(v); ++i)
    #define lp(i, n) for (int i = 0; i < (int)(n); ++i)
    #define lpi(i, j, n) for (int i = (j); i < (int)(n); ++i)
    #define lpd(i, j, n) for (int i = (j); i >= (int)(n); --i)
    #define vi vector<int>
    #define vl vector<ll>
    #define ii pair<ll, ll>
    #define vii vector<ii>
    #define PIii double PPPPPP = 3.14159265358979323846;
    #define pb push_back
    using namespace std;
    const int N = 2e5 + 5;
    int vis[N];
    void run() {
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr), cout.tie(nullptr);
    }
    int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
        run();
        int tt=1;
       // cin>>tt;
        while(tt--)
        {
            int n,ans=0;
            cin>>n;
            vi v(n);
            for(int&i:v)cin>>i;
            for(int&i:v)
                ans+=i!=v.back();
            cout<<ans<<endl;
            for (int i = n-2; i >=0 ; --i) {
                if(v[i]>v.back())
                    cout<<2<<' '<<i+1<<' '<<i+2<<endl;
                if(v[i]<v.back())
                    cout<<1<<' '<<i+1<<' '<<i+2<<endl;
            }
        }

        return 0;
    }


    #include <bits/stdc++.h>
    #define endl "\n"
    #define ll long long
    #define all(v) ((v).begin()), ((v).end())
    #define sz(v) ((int)((v).size()))
    #define clr(v, d) memset(v, d, sizeof(v))
    #define rep(i, v) for (int i = 0; i < sz(v); ++i)
    #define lp(i, n) for (int i = 0; i < (int)(n); ++i)
    #define lpi(i, j, n) for (int i = (j); i < (int)(n); ++i)
    #define lpd(i, j, n) for (int i = (j); i >= (int)(n); --i)
    #define vi vector<int>
    #define vl vector<ll>
    #define ii pair<ll, ll>
    #define vii vector<ii>
    #define PIii double PPPPPP = 3.14159265358979323846;
    #define pb push_back
    using namespace std;
    const int N = 2e5 + 5;
    int vis[N];
    void run() {
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr), cout.tie(nullptr);
    }
    int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
        run();
        int tt=1;
       // cin>>tt;
        while(tt--)
        {
            ll n,ans=0;
            cin>>n;
            vl v(n);
            for(ll&i:v)cin>>i;
            for(ll&i:v)
                ans+=i!=v.back();
            cout<<ans<<endl;
            for (int i = n-2; i >=0 ; --i) {
                if(v[i]>v.back())
                    cout<<2<<' '<<i+1<<' '<<i+2<<endl;
                if(v[i]<v.back())
                    cout<<1<<' '<<i+1<<' '<<i+2<<endl;
            }
        }

        return 0;
    }


    #include <bits/stdc++.h>
    #define endl "\n"
    #define ll long long
    #define all(v) ((v).begin()), ((v).end())
    #define sz(v) ((int)((v).size()))
    #define clr(v, d) memset(v, d, sizeof(v))
    #define rep(i, v) for (int i = 0; i < sz(v); ++i)
    #define lp(i, n) for (int i = 0; i < (int)(n); ++i)
    #define lpi(i, j, n) for (int i = (j); i < (int)(n); ++i)
    #define lpd(i, j, n) for (int i = (j); i >= (int)(n); --i)
    #define vi vector<int>
    #define vl vector<ll>
    #define ii pair<ll, ll>
    #define vii vector<ii>
    #define PIii double PPPPPP = 3.14159265358979323846;
    #define pb push_back
    using namespace std;
    const int N = 2e5 + 5;
    int vis[N];
    void run() {
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr), cout.tie(nullptr);
    }
    int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
        run();
        int tt=1;
       // cin>>tt;
        while(tt--)
        {
            int n,ans=0;
            cin>>n;
            vi v(n);
            for(int&i:v)cin>>i;
            for(int&i:v)
                ans+=i!=v.back();
            cout<<ans<<endl;
            reverse(all(v));
            for(int i=0;i+1<n;i++)
            {
                    if(v[i]>v[i+1]) {
                        cout << 2 <<' '<< n - i - 1 << ' ' << n - i << endl;
                        v[i+1]=v[i];
                    }
                    if(v[i]<v[i+1]) {
                        cout << 1 << ' '<<n - i - 1 << ' ' << n - i << endl;
                        v[i + 1] = v[i];
                    }
            }
        }

        return 0;
    }


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;

//vector<int>cnt(100001,0);
int main() {
	int n;
	cin>>n;
	vector<int>v(n);
	map<int,int>cnt;
	int max1=0;
	int val=-1;
	for(int i=0;i<n;i++)
	{
	cin>>v[i];
	cnt[v[i]]++;
	//cout<<v[i]<<" "<<cnt[v[i]]<<endl;
	if(cnt[v[i]]>max1)
	{
	    max1=cnt[v[i]];
	    val=v[i];
	}
	}

	int ind;
	for(int i=0;i<n;i++){
	if(v[i]==val){
	ind=i;
	break;}}
	//cout<<max1<<" ";
	cout<<n-max1<<endl;
	for(int i=ind-1;i>=0;i--)
	{
	    cout<<"1 "<<i+1<<" "<<i+2<<endl;
	}
	for(int i=ind+1;i<n;i++)
	{
	    if(v[i]==val)
	    continue;

	    cout<<"2 "<<i<<" "<<i+1<<endl;
	}
	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;

//vector<int>cnt(100001,0);
int main() {
	int n;
	cin>>n;
	vector<int>v(n);
	map<int,int>cnt;
	int max1=0;
	int val=-1;
	for(int i=0;i<n;i++)
	{
	cin>>v[i];
	cnt[v[i]]++;
	//cout<<v[i]<<" "<<cnt[v[i]]<<endl;
	if(cnt[v[i]]>max1)
	{
	    max1=cnt[v[i]];
	    val=v[i];
	}
	}

	int ind;
	for(int i=0;i<n;i++){
	if(v[i]==val){
	ind=i;
//	break;
    }}
	//cout<<max1<<" ";
	cout<<n-max1<<endl;
	for(int i=ind-1;i>=0;i--)
	{
	    if(v[i]==val)
	    continue;
	    if(v[i]>val)
	    {
	        cout<<"2 "<<i+1<<" "<<i+2<<endl;
	    }
	    else
	    cout<<"1 "<<i+1<<" "<<i+2<<endl;
	}
	for(int i=ind+1;i<n;i++)
	{
	    if(v[i]==val)
	    continue;
	    if(v[i]>val)
	    cout<<"2 "<<i+1<<" "<<i<<endl;
	    else
	    cout<<"2 "<<i+1<<" "<<i<<endl;
	}
	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;

vector<int>cnt(100001,0);
int main() {
	int n;
	cin>>n;
	vector<int>v(n);

	int max1=0;
	int val=-1;
	for(int i=0;i<n;i++)
	{
	cin>>v[i];
	cnt[v[i]]++;
	//cout<<v[i]<<" "<<cnt[v[i]]<<endl;
	if(cnt[v[i]]>max1)
	{
	    max1=cnt[v[i]];
	    val=v[i];
	}
	}

	int ind;
	for(int i=0;i<n;i++){
	if(v[i]==val){
	ind=i;
	break;}}
	//cout<<max1<<" ";
	cout<<n-max1<<endl;
	for(int i=ind-1;i>=0;i--)
	{
	    cout<<"1 "<<i+1<<" "<<i+2<<endl;
	}
	for(int i=ind+1;i<n;i++)
	{
	    if(v[i]==val)
	    continue;

	    cout<<"2 "<<i+1<<" "<<i<<endl;
	}
	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;

//vector<int>cnt(100001,0);
int main() {
	int n;
	cin>>n;
	vector<int>v(n);
	map<int,int>cnt;
	int max11=0;
	int val=-1;
	for(int i=0;i<n;i++)
	{
	cin>>v[i];
	cnt[v[i]]++;
	//cout<<v[i]<<" "<<cnt[v[i]]<<endl;
	if(cnt[v[i]]>max11)
	{
	    max11=cnt[v[i]];
	    val=v[i];
	}
	}

	int ind;
	for(int i=0;i<n;i++){
	if(v[i]==val){
	ind=i;
	break;}}
	//cout<<max1<<" ";
	cout<<n-max11<<endl;
	for(int i=ind-1;i>=0;i--)
	{
	    cout<<"1 "<<i+1<<" "<<i+2<<endl;
	}
	for(int i=ind+1;i<n;i++)
	{
	    if(v[i]==val)
	    continue;

	    cout<<"2 "<<i+1<<" "<<i<<endl;
	}
	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;

//vector<int>cnt(100001,0);
int main() {
	int n;
	cin>>n;
	vector<int>v(n);
	map<int,int>cnt;
	int max1=0;
	int val=-1;
	for(int i=0;i<n;i++)
	{
	cin>>v[i];
	cnt[v[i]]++;
	//cout<<v[i]<<" "<<cnt[v[i]]<<endl;
	if(cnt[v[i]]>max1)
	{
	    max1=cnt[v[i]];
	    val=v[i];
	}
	}

	int ind;
	for(int i=0;i<n;i++){
	if(v[i]==val){
	ind=i;
//	break;
    }}
	//cout<<max1<<" ";
	cout<<n-max1<<endl;
	for(int i=ind-1;i>=0;i--)
	{
	    if(v[i]==val)
	    continue;
	    if(v[i]>val)
	    {
	        cout<<"2 "<<i+1<<" "<<i+2<<endl;
	    }
	    else
	    cout<<"1 "<<i+1<<" "<<i+2<<endl;
	}
	for(int i=ind+1;i<n;i++)
	{
	    if(v[i]==val)
	    continue;
	    if(v[i]>val)
	    cout<<"2 "<<i+1<<" "<<i<<endl;
	    else
	    cout<<"1 "<<i+1<<" "<<i<<endl;
	}
	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;

//vector<int>cnt(100001,0);
int main() {
	int n;
	cin>>n;
	vector<int>v(n);
	map<int,int>cnt;
	int max1=0;
	int val=-1;
	for(int i=0;i<n;i++)
	{
	cin>>v[i];
	cnt[v[i]]++;
	//cout<<v[i]<<" "<<cnt[v[i]]<<endl;
	if(cnt[v[i]]>=max1)
	{
	    max1=cnt[v[i]];
	    val=v[i];
	}
	}

	int ind;
	for(int i=0;i<n;i++){
	if(v[i]==val){
	ind=i;
	break;}}
	//cout<<max1<<" ";
	cout<<n-max1<<endl;
	for(int i=ind-1;i>=0;i--)
	{
	    cout<<"1 "<<i+1<<" "<<i+2<<endl;
	}
	for(int i=ind+1;i<n;i++)
	{
	    if(v[i]==val)
	    continue;

	    cout<<"2 "<<i+1<<" "<<i<<endl;
	}
	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;

int main() {
	int n;
	cin>>n;
	vector<int>v(n);
	vector<int>cnt(100001,0);
	int max1=0;
	int val=-1;
	for(int i=0;i<n;i++)
	{
	cin>>v[i];
	cnt[v[i]]++;
	//cout<<v[i]<<" "<<cnt[v[i]]<<endl;
	if(cnt[v[i]]>max1)
	{
	    max1=cnt[v[i]];
	    val=v[i];
	}
	}

	int ind;
	for(int i=0;i<n;i++){
	if(v[i]==val){
	ind=i;
	break;}}
	//cout<<max1<<" ";
	cout<<n-max1<<endl;
	for(int i=ind-1;i>=0;i--)
	{
	    cout<<"1 "<<i+1<<" "<<i+2<<endl;
	}
	for(int i=ind+1;i<n;i++)
	{
	    if(v[i]==val)
	    continue;

	    cout<<"2 "<<i+1<<" "<<i<<endl;
	}
	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;

//vector<int>cnt(100001,0);
int main() {
	int n;
	cin>>n;
	vector<int>v(n);
	map<int,int>cnt;
	int max1=0;
	int val=-1;
	for(int i=0;i<n;i++)
	{
	cin>>v[i];
	cnt[v[i]]++;
	//cout<<v[i]<<" "<<cnt[v[i]]<<endl;
	if(cnt[v[i]]>max1)
	{
	    max1=cnt[v[i]];
	    val=v[i];
	}
	}

	int ind;
	for(int i=0;i<n;i++){
	if(v[i]==val){
	ind=i;
//	break;
    }}
	//cout<<max1<<" ";
	cout<<n-max1<<endl;
	for(int i=ind-1;i>=0;i--)
	{
	    if(v[i]==val)
	    continue;

	    cout<<"1 "<<i+1<<" "<<i+2<<endl;
	}
	for(int i=ind+1;i<n;i++)
	{
	    if(v[i]==val)
	    continue;

	    cout<<"2 "<<i+1<<" "<<i<<endl;
	}
	return 0;
}