#include<bits/stdc++.h>
using namespace std;
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define pii pair<ll,ll>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp make_pair
#define ll long long int
#define Q queue<pair<int,int>>
struct data{
  int op,p,q;

};

int main()
{
int n;
cin>>n;
int i;
int a[500005];
int b[500005];
vector <int> hash(500005,0);
for(i=0;i<200000;i++)
	hash[i]=0;
for(int i=0;i<n;i++)
{
	cin>>a[i];
	//b[a[i]]=i;
	hash[a[i]]++;
}
int x;
int max=0;
int pos;
for(i=0;i<n;i++)
{
	if(max<hash[a[i]])
	{
		max=hash[a[i]];
		pos=i;
		x=a[i];
	}
}
  printf("%d\n",n-hash[x]);

  for(i=pos-1;i>=0;i--)
  {
    if(x>a[i])
    {
      printf("1 %d %d\n",i+1,i+2);
    }
    else if(x < a[i])
    {
      printf("2 %d %d\n",i+1,i+2);
    }
  }
  for(i=pos+1;i<n;i++)
  {
    //debug1(i);
    //cout<<endl;
    if(x>a[i])
    {
      printf("1 %d %d\n",i+1,i);
    }
    else if(x < a[i])
    {
      printf("2 %d %d\n",i+1,i);
    }
  }
  //cout<<v1.size()<<endl;
  //for(i=0;i<v1.size();i++)
    //printf("%d %d %d\n",v1[i].op,v1[i].p+1,v1[i].q+1);

}


#include<bits/stdc++.h>
using namespace std;
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define pii pair<ll,ll>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp make_pair
#define ll long long int
#define Q queue<pair<int,int>>
struct data{
  int op,p,q;

};

int main()
{
  int n;
  cin>>n;
  int i;
 int a[200005];
  int b[200005];
  for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[a[i]]=i;
    }
  int hash[200005];
  for(i=0;i<200005;i++)
    hash[i]=0;
  for(int i=0;i<n;i++)
  {
    hash[a[i]]++;
  }
  int max=0,j=0;
  for(i=0;i<200004;i++)
    if(hash[i]>max)
      j=i;
  int p=b[i];
  int x=j;
  vector <struct data> v1;
  //debug2(p,x);
  for(i=p-1;i>=0;i--)
  {
    if(x>a[i])
    {
      v1.push_back({1,i,i+1});
    }
    else if(x < a[i])
    {
      v1.push_back({2,i,i+1});
    }
  }
  for(i=p;i<n;i++)
  {
    if(x>a[i])
    {
      v1.push_back({1,i,i+1});
    }
    else if(x < a[i])
    {
      v1.push_back({2,i,i+1});
    }
  }
  cout<<v1.size()<<endl;
  for(i=0;i<v1.size();i++)
    printf("%d %d %d\n",v1[i].op,v1[i].p+1,v1[i].q+1);

}


#include<bits/stdc++.h>
using namespace std;
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define pii pair<ll,ll>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp make_pair
#define ll long long int
#define Q queue<pair<int,int>>
struct data{
  int op,p,q;

};

int main()
{
int n;
cin>>n;
int i;
int a[500005];
int b[500005];
vector <int> hash(500005,0);
for(i=0;i<200000;i++)
	hash[i]=0;
for(int i=0;i<n;i++)
{
	cin>>a[i];
	//b[a[i]]=i;
	hash[a[i]]++;
}
int x;
int max=0;
int pos;
for(i=0;i<n;i++)
{
	if(max<hash[a[i]])
	{
		max=hash[a[i]];
		pos=i;
		x=a[i];
	}
}
  printf("%d\n",n-hash[x]);
  for(i=pos+1;i<n;i++)
  {
    //debug1(i);
    //cout<<endl;
    if(x>a[i])
    {
      printf("1 %d %d\n",i+1,i);
    }
    else if(x < a[i])
    {
      printf("2 %d %d\n",i+1,i);
    }
  }
  for(i=pos-1;i>=0;i--)
  {
    if(x>a[i])
    {
      printf("1 %d %d\n",i+1,i+2);
    }
    else if(x < a[i])
    {
      printf("2 %d %d\n",i+1,i+2);
    }
  }
  //cout<<v1.size()<<endl;
  //for(i=0;i<v1.size();i++)
    //printf("%d %d %d\n",v1[i].op,v1[i].p+1,v1[i].q+1);

}


#include<bits/stdc++.h>
using namespace std;
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define pii pair<ll,ll>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp make_pair
#define ll long long int
#define Q queue<pair<int,int>>
struct data{
  int op,p,q;

};

int main()
{
int n;
cin>>n;
int i;
int a[500005];
int b[500005];
vector <int> hash(500005,0);
for(i=0;i<500005;i++)
	hash[i]=0;
for(int i=0;i<n;i++)
{
	cin>>a[i];
	//b[a[i]]=i;
	hash[a[i]]++;
}
int max=0;
int pos;
for(i=0;i<200005;i++)
{
	if(max<hash[i])
	{
		max=hash[i];
		pos=i;
	}
}
//debug1(pos);
  vector <struct data> v1;
  int x=max;
  int c;
  for(i=0;i<n;i++)
  {
  	if(pos==a[i])
  		{
  			c=i;break;}
  }
x=pos;
  pos=c;
  //debug2(pos,c);
  //debug3(pos,x,n);
  printf("%d\n",n-hash[x]);
  for(i=pos+1;i<n;i++)
  {
    //debug1(i);
    //cout<<endl;
    if(x>a[i])
    {
      printf("1 %d %d\n",i+1,i);
    }
    else if(x < a[i])
    {
      printf("2 %d %d\n",i+1,i);
    }
  }
  for(i=pos-1;i>=0;i--)
  {
    if(x>a[i])
    {
      printf("1 %d %d\n",i+1,i+2);
    }
    else if(x < a[i])
    {
      printf("1 %d %d\n",i+1,i+2);
    }
  }
  //cout<<v1.size()<<endl;
  //for(i=0;i<v1.size();i++)
    //printf("%d %d %d\n",v1[i].op,v1[i].p+1,v1[i].q+1);

}


#include<bits/stdc++.h>
using namespace std;
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define pii pair<ll,ll>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp make_pair
#define ll long long int
#define Q queue<pair<int,int>>
struct data{
  int op,p,q;

};

int main()
{
int n;
cin>>n;
int i;
int a[200005];
int b[200005];
int hash[200005];
for(i=0;i<200005;i++)
	hash[i]=0;
for(int i=0;i<n;i++)
{
	cin>>a[i];
	hash[a[i]]++;
}
int max=0;
int pos;
for(i=0;i<n;i++)
{
	if(max<hash[a[i]])
	{
		max=a[i];
		pos=i;
	}
}
  vector <struct data> v1;
  int x=max;

  //debug2(pos,x);
  for(i=pos+1;i<n;i++)
  {
    if(x>a[i])
    {
      v1.push_back({1,i,i-1});
    }
    else if(x < a[i])
    {
      v1.push_back({2,i,i-1});
    }
  }
  for(i=pos-1;i>=0;i--)
  {
    if(x>a[i])
    {
      v1.push_back({1,i,i+1});
    }
    else if(x < a[i])
    {
      v1.push_back({2,i,i+1});
    }
  }
  cout<<v1.size()<<endl;
  for(i=0;i<v1.size();i++)
    printf("%d %d %d\n",v1[i].op,v1[i].p+1,v1[i].q+1);

}


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)
#define ios                     ios_base::sync_with_stdio(false);cin.tie(NULL);

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n) {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }
    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){
    int ans=1;
    while(b){
        if(b&1ll){
            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }
    return ans;
}
int inverse(int a,int mod1){
    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////

signed main(){
    ios
    int n; cin>>n;
    int a[n+1],indx=-1,val=-1,max_cnt=-1;
    map<int,int> cnt;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cnt[a[i]]++;
        if(max_cnt<cnt[a[i]]){
            max_cnt=cnt[a[i]];
            indx=i;
            val=a[i];
        }
    }

    map<int,vector<pair<int,int> > > ans;
    int op=0;
    for(int i=indx-1;i>=1;i--){
        if(a[i]<val){
            ans[1].pb({i,i+1});
            op++;
        }
        else if(a[i]>val){
            ans[2].pb({i,i+1});
            op++;
        }
    }
    for(int i=indx+1;i<=n;i++){
        if(a[i]<val){
            ans[1].pb({i-1,i});
            op++;
        }
        else if(a[i]>val){
            ans[2].pb({i-1,i});
            op++;
        }
    }

    cout<<op<<endl;
    for(auto x:ans){
        for(auto y:x.second){
            cout<<x.first<<" "<<y.first<<" "<<y.second<<endl;
        }
    }

    return 0;
}

/*

*/


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)
#define ios                     ios_base::sync_with_stdio(false);cin.tie(NULL);

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n) {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }
    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){
    int ans=1;
    while(b){
        if(b&1ll){
            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }
    return ans;
}
int inverse(int a,int mod1){
    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////

signed main(){
    ios
    int n; cin>>n;
    int a[n+1];
    int mx=INT_MIN,mx_i=-1,mn=INT_MAX,mn_i=-1;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(mx<a[i]){
            mx=a[i];
            mx_i=i;
        }
        if(mn>a[i]){
            mn=a[i];
            mn_i=i;
        }
    }

    vector<pair<int,int> > ans1;
    int op1=0;
    for(int i=mx_i-1;i>=1;i--){
        if(a[i]!=mx){
            ans1.pb({i,i+1});
            op1++;
        }
    }
    for(int i=mx_i+1;i<=n;i++){
        if(a[i]!=mx){
            ans1.pb({i-1,i});
            op1++;
        }
    }

    vector<pair<int,int> > ans2;
    int op2=0;
    for(int i=mn_i-1;i>=1;i--){
        if(a[i]!=mn){
            ans2.pb({i+1,i});
            op2++;
        }
    }
    for(int i=mn_i+1;i<=n;i++){
        if(a[i]!=mn){
            ans2.pb({i,i-1});
            op2++;
        }
    }

    if(op1<op2){
        cout<<ans1.size()<<endl;
        for(auto x:ans1){
            cout<<1<<" "<<x.first<<" "<<x.second<<endl;
        }
    }
    else{
        cout<<ans2.size()<<endl;
        for(auto x:ans2){
            cout<<2<<" "<<x.first<<" "<<x.second<<endl;
        }
    }

    return 0;
}

/*

*/


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)
#define ios                     ios_base::sync_with_stdio(false);cin.tie(NULL);

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n) {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }
    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){
    int ans=1;
    while(b){
        if(b&1ll){
            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }
    return ans;
}
int inverse(int a,int mod1){
    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////

signed main(){
    ios
    int n; cin>>n;
    int a[n+1];
    int mx=INT_MIN,mx_i=-1,mn=INT_MAX,mn_i=-1;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(mx<a[i]){
            mx=a[i];
            mx_i=i;
        }
        if(mn>a[i]){
            mn=a[i];
            mn_i=i;
        }
    }

    vector<pair<int,int> > ans1;
    int op1=0;
    for(int i=mx_i-1;i>=1;i--){
        if(a[i]!=mx){
            ans1.pb({i,i+1});
            op1++;
        }
    }
    for(int i=mx_i+1;i<=n;i++){
        if(a[i]!=mx){
            ans1.pb({i-1,i});
            op1++;
        }
    }

    vector<pair<int,int> > ans2;
    int op2=0;
    for(int i=mn_i-1;i>=1;i--){
        if(a[i]!=mn){
            ans2.pb({i,i+1});
            op2++;
        }
    }
    for(int i=mn_i+1;i<=n;i++){
        if(a[i]!=mn){
            ans2.pb({i,i-1});
            op2++;
        }
    }

    if(op1<op2){
        cout<<ans1.size()<<endl;
        for(auto x:ans1){
            cout<<1<<" "<<x.first<<" "<<x.second<<endl;
        }
    }
    else{
        cout<<ans2.size()<<endl;
        for(auto x:ans2){
            cout<<2<<" "<<x.first<<" "<<x.second<<endl;
        }
    }

    return 0;
}

/*

*/


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)
#define ios                     ios_base::sync_with_stdio(false);cin.tie(NULL);

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n) {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }
    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){
    int ans=1;
    while(b){
        if(b&1ll){
            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }
    return ans;
}
int inverse(int a,int mod1){
    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////

signed main(){
    ios
    int n; cin>>n;
    int a[n+1],indx=-1,val=-1,max_cnt=-1;
    map<int,int> cnt;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cnt[a[i]]++;
        if(max_cnt<cnt[a[i]]){
            max_cnt=cnt[a[i]];
            indx=i;
            val=a[i];
        }
    }

    unordered_map<int,vector<pair<int,int> > > ans;
    int op=0;
    for(int i=indx-1;i>=1;i--){
        if(a[i]<val){
            ans[1].pb({i+1,i});
            op++;
        }
        else if(a[i]>val){
            ans[2].pb({i+1,i});
            op++;
        }
    }
    for(int i=indx+1;i<=n;i++){
        if(a[i]<val){
            ans[1].pb({i,i-1});
            op++;
        }
        else if(a[i]>val){
            ans[2].pb({i,i-1});
            op++;
        }
    }

    cout<<op<<endl;
    for(auto x:ans){
        for(auto y:x.second){
            cout<<x.first<<" "<<y.first<<" "<<y.second<<endl;
        }
    }

    return 0;
}

/*

*/


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)
#define ios                     ios_base::sync_with_stdio(false);cin.tie(NULL);

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n) {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }
    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){
    int ans=1;
    while(b){
        if(b&1ll){
            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }
    return ans;
}
int inverse(int a,int mod1){
    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////

signed main(){
    ios
    int n; cin>>n;
    int a[n+1],indx=-1,val=-1,max_cnt=-1;
    map<int,int> cnt;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cnt[a[i]]++;
        if(max_cnt<cnt[a[i]]){
            max_cnt=cnt[a[i]];
            indx=i;
            val=a[i];
        }
    }

    unordered_map<int,vector<pair<int,int> > > ans;
    int op=0;
    for(int i=indx-1;i>=1;i--){
        if(a[i]<val){
            ans[1].pb({i,i+1});
            op++;
        }
        else if(a[i]>val){
            ans[2].pb({i+1,i});
            op++;
        }
    }
    for(int i=indx+1;i<=n;i++){
        if(a[i]<val){
            ans[1].pb({i-1,i});
            op++;
        }
        else if(a[i]>val){
            ans[2].pb({i,i-1});
            op++;
        }
    }

    cout<<op<<endl;
    for(auto x:ans){
        for(auto y:x.second){
            cout<<x.first<<" "<<y.first<<" "<<y.second<<endl;
        }
    }

    return 0;
}

/*

*/


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)
#define ios                     ios_base::sync_with_stdio(false);cin.tie(NULL);

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n) {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }
    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){
    int ans=1;
    while(b){
        if(b&1ll){
            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }
    return ans;
}
int inverse(int a,int mod1){
    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////

signed main(){
    ios
    int n; cin>>n;
    int a[n+1],indx=-1,val=-1,max_cnt=-1;
    map<int,int> cnt;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cnt[a[i]]++;
        if(max_cnt<cnt[a[i]]){
            max_cnt=cnt[a[i]];
            indx=i;
            val=a[i];
        }
    }

    unordered_map<int,vector<pair<int,int> > > ans;
    int op=0;
    for(int i=indx-1;i>=1;i--){
        if(a[i]<val){
            ans[1].pb({i+1,i});
            op++;
        }
        else if(a[i]>val){
            ans[2].pb({i,i+1});
            op++;
        }
    }
    for(int i=indx+1;i<=n;i++){
        if(a[i]<val){
            ans[1].pb({i,i-1});
            op++;
        }
        else if(a[i]>val){
            ans[2].pb({i-1,i});
            op++;
        }
    }

    cout<<op<<endl;
    for(auto x:ans){
        for(auto y:x.second){
            cout<<x.first<<" "<<y.first<<" "<<y.second<<endl;
        }
    }

    return 0;
}

/*

*/


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)
#define ios                     ios_base::sync_with_stdio(false);cin.tie(NULL);

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n) {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }
    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){
    int ans=1;
    while(b){
        if(b&1ll){
            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }
    return ans;
}
int inverse(int a,int mod1){
    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////

signed main(){
    ios
    int n; cin>>n;
    int a[n+1];
    int mx=INT_MIN,mx_i=-1,mn=INT_MAX,mn_i=-1;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(mx<a[i]){
            mx=a[i];
            mx_i=i;
        }
        if(mn>a[i]){
            mn=a[i];
            mn_i=i;
        }
    }

    vector<pair<int,int> > ans1;
    int op1=0;
    for(int i=mx_i-1;i>=1;i--){
        if(a[i]!=mx){
            ans1.pb({i,i+1});
            op1++;
        }
    }
    for(int i=mx_i+1;i<=n;i++){
        if(a[i]!=mx){
            ans1.pb({i-1,i});
            op1++;
        }
    }

    vector<pair<int,int> > ans2;
    int op2=0;
    for(int i=mn_i-1;i>=1;i--){
        if(a[i]!=mn){
            ans2.pb({i,i+1});
            op2++;
        }
    }
    for(int i=mn_i+1;i<=n;i++){
        if(a[i]!=mn){
            ans2.pb({i-1,i});
            op2++;
        }
    }

    if(op1<op2){
        cout<<ans1.size()<<endl;
        for(auto x:ans1){
            cout<<1<<" "<<x.first<<" "<<x.second<<endl;
        }
    }
    else{
        cout<<ans2.size()<<endl;
        for(auto x:ans2){
            cout<<2<<" "<<x.first<<" "<<x.second<<endl;
        }
    }

    return 0;
}

/*

*/


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)
#define ios                     ios_base::sync_with_stdio(false);cin.tie(NULL);

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n) {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }
    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){
    int ans=1;
    while(b){
        if(b&1ll){
            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }
    return ans;
}
int inverse(int a,int mod1){
    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////

signed main(){
    ios
    int n; cin>>n;
    int a[n+1],indx=-1,val=-1,max_cnt=-1;
    map<int,int> cnt;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cnt[a[i]]++;
        if(max_cnt<cnt[a[i]]){
            max_cnt=cnt[a[i]];
            indx=i;
            val=a[i];
        }
    }

    unordered_map<int,vector<pair<int,int> > > ans;
    int op=0;
    for(int i=indx-1;i>=1;i--){
        if(a[i]<val){
            ans[1].pb({i,i+1});
            op++;
        }
        else if(a[i]>val){
            ans[2].pb({i,i+1});
            op++;
        }
    }
    for(int i=indx+1;i<=n;i++){
        if(a[i]<val){
            ans[1].pb({i,i-1});
            op++;
        }
        else if(a[i]>val){
            ans[2].pb({i,i-1});
            op++;
        }
    }

    cout<<op<<endl;
    for(auto x:ans){
        for(auto y:x.second){
            cout<<x.first<<" "<<y.first<<" "<<y.second<<endl;
        }
    }

    return 0;
}

/*

*/


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)
#define ios                     ios_base::sync_with_stdio(false);cin.tie(NULL);

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n) {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }
    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){
    int ans=1;
    while(b){
        if(b&1ll){
            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }
    return ans;
}
int inverse(int a,int mod1){
    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////

signed main(){
    ios
    int n; cin>>n;
    int a[n+1],indx=-1,val=-1,max_cnt=-1;
    map<int,int> cnt;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cnt[a[i]]++;
        if(max_cnt<cnt[a[i]]){
            max_cnt=cnt[a[i]];
            indx=i;
            val=a[i];
        }
    }

    unordered_map<int,vector<pair<int,int> > > ans;
    int op=0;
    for(int i=indx-1;i>=1;i--){
        if(a[i]<val){
            ans[1].pb({i,i+1});
            op++;
        }
        else if(a[i]>val){
            ans[2].pb({i,i+1});
            op++;
        }
    }
    for(int i=indx+1;i<=n;i++){
        if(a[i]<val){
            ans[1].pb({i,i-1});
            op++;
        }
        else if(a[i]>val){
            ans[2].pb({i-1,i});
            op++;
        }
    }

    cout<<op<<endl;
    for(auto x:ans){
        for(auto y:x.second){
            cout<<x.first<<" "<<y.first<<" "<<y.second<<endl;
        }
    }

    return 0;
}

/*

*/


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)
#define ios                     ios_base::sync_with_stdio(false);cin.tie(NULL);

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n) {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }
    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){
    int ans=1;
    while(b){
        if(b&1ll){
            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }
    return ans;
}
int inverse(int a,int mod1){
    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////

signed main(){
    ios
    int n; cin>>n;
    int a[n+1],indx=-1,val=-1,max_cnt=-1;
    map<int,int> cnt;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cnt[a[i]]++;
        if(max_cnt<cnt[a[i]]){
            max_cnt=cnt[a[i]];
            indx=i;
            val=a[i];
        }
    }

    unordered_map<int,vector<pair<int,int> > > ans;
    int op=0;
    for(int i=indx-1;i>=1;i--){
        if(a[i]<val){
            ans[1].pb({i+1,i});
            op++;
        }
        else if(a[i]>val){
            ans[2].pb({i+1,i});
            op++;
        }
    }
    for(int i=indx+1;i<=n;i++){
        if(a[i]<val){
            ans[1].pb({i,i-1});
            op++;
        }
        else if(a[i]>val){
            ans[2].pb({i-1,i});
            op++;
        }
    }

    cout<<op<<endl;
    for(auto x:ans){
        for(auto y:x.second){
            cout<<x.first<<" "<<y.first<<" "<<y.second<<endl;
        }
    }

    return 0;
}

/*

*/


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)
#define ios                     ios_base::sync_with_stdio(false);cin.tie(NULL);

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n) {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }
    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){
    int ans=1;
    while(b){
        if(b&1ll){
            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }
    return ans;
}
int inverse(int a,int mod1){
    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
class points{
public:
    int a,b,c;
};

signed main(){
    ios
    int n; cin>>n;
    int a[n+1],indx=-1,val=-1,max_cnt=-1;
    map<int,int> cnt;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cnt[a[i]]++;
        if(max_cnt<cnt[a[i]]){
            max_cnt=cnt[a[i]];
            indx=i;
            val=a[i];
        }
    }

    vector<points> ans;
    for(int i=indx-1;i>=1;i--){
        if(a[i]<val){
            ans.pb({1,i,i+1});
        }
        else if(a[i]>val){
            ans.pb({2,i,i+1});
        }
    }
    for(int i=indx+1;i<=n;i++){
        if(a[i]<val){
            ans.pb({1,i,i-1});
        }
        else if(a[i]>val){
            ans.pb({2,i,i-1});
        }
    }

    cout<<ans.size()<<endl;
    for(auto x:ans){
        cout<<x.a<<" "<<x.b<<" "<<x.c<<endl;
    }

    return 0;
}

/*

*/


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)
#define ios                     ios_base::sync_with_stdio(false);cin.tie(NULL);

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n) {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }
    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){
    int ans=1;
    while(b){
        if(b&1ll){
            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }
    return ans;
}
int inverse(int a,int mod1){
    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////

signed main(){
    ios
    int n; cin>>n;
    int a[n+1],indx=-1,val=-1,max_cnt=-1;
    map<int,int> cnt;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cnt[a[i]]++;
        if(max_cnt<cnt[a[i]]){
            max_cnt=cnt[a[i]];
            indx=i;
            val=a[i];
        }
    }

    map<int,vector<pair<int,int> > > ans;
    int op=0;
    for(int i=indx-1;i>=1;i--){
        if(a[i]<val){
            ans[1].pb({i,i+1});
            op++;
        }
        else if(a[i]>val){
            ans[2].pb({i,i+1});
            op++;
        }
    }
    for(int i=indx+1;i<=n;i++){
        if(a[i]<val){
            ans[1].pb({i,i-1});
            op++;
        }
        else if(a[i]>val){
            ans[2].pb({i,i-1});
            op++;
        }
    }

    cout<<op<<endl;
    for(auto x:ans){
        for(auto y:x.second){
            cout<<x.first<<" "<<y.first<<" "<<y.second<<endl;
        }
    }

    return 0;
}

/*

*/


#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define fin for(i=0;i<n;i++)
#define fjn for(j=0;j<n;j++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
#define getline(cin,s) get
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define ef else if
#define SORT(A) sort(A.begin(), A.end());
#define modu 998244353
#define sz(x)   (int)x.size()
#define REVERSE(A) reverse(A.begin(), A.end());
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
bool cmp(string a,string b)
{
    return sz(a)<sz(b);
}
ll myXOR(ll x, ll y)
{
  return (x|y)&(~x|~y);
}
ll powerLL(ll x, ll n)
{
    ll result = 1;
    while (n) {
        if (n & 1)
            result = result * x % mod;
        n = n / 2;
        x = x * x % mod;
    }
    return result;
}
set<ll>s;
void printDivisors(ll n)
{
    for (ll i=1; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            // If divisors are equal, print only one
            if (n/i == i)
              s.insert(i);

            else
            {
                // printf("%d %d ", i, n/i);
                s.insert(i);
                s.insert(n/i);
            }
        }
    }
}
class gfg
{

/* Function to calculate x raised to the power y */
public:
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
};
unsigned int countBits(unsigned int n)
{
   unsigned int count = 0;
   while (n)
   {
        count++;
        n >>= 1;
    }
    return count;
}
int main()
{
  ll t,n,m,i,a,b,c,j,l,r,x,u,v,y,z,k,d,nl,np,q;
  gfg g;
  cin>>n;
  vector<ll>vr(n),cnt(200000,0);
  rep(i,0,n)
  {
    cin>>vr[i];
    cnt[vr[i]]++;
  }
  ll val = max_element(cnt.begin(),cnt.end())-cnt.begin();
  // cout<<val<<endl;
  ll pos = find(vr.begin(),vr.end(),val) - vr.begin();
  // cout<<pos<<endl;

  cout<<n-cnt[val]<<endl;
  for(int i=pos;i>=1;i--)
  {
     if(vr[i-1]!=val)
     {
        if(vr[i-1]>val)
        {
            cout<<2<<" "<<i<<" "<<i+1<<endl;
        }
        else
        {
            cout<<1<<" "<<i<<" "<<i+1<<endl;
        }
     }
  }
  for(int i=pos;i<n-1;i++)
  {
    if(vr[i+1]!=val)
    {
        if(vr[i+1]>val)
        {
            cout<<2<<" "<<i+2<<" "<<i+1<<endl;
        }
        else
        {
            cout<<1<<" "<<i+2<<" "<<i+1<<endl;
        }
    }
  }

}


#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define fin for(i=0;i<n;i++)
#define fjn for(j=0;j<n;j++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
#define getline(cin,s) get
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define ef else if
#define SORT(A) sort(A.begin(), A.end());
#define modu 998244353
#define sz(x)   (int)x.size()
#define REVERSE(A) reverse(A.begin(), A.end());
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
bool cmp(string a,string b)
{
    return sz(a)<sz(b);
}
ll myXOR(ll x, ll y)
{
  return (x|y)&(~x|~y);
}
ll powerLL(ll x, ll n)
{
    ll result = 1;
    while (n) {
        if (n & 1)
            result = result * x % mod;
        n = n / 2;
        x = x * x % mod;
    }
    return result;
}
set<ll>s;
void printDivisors(ll n)
{
    for (ll i=1; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            // If divisors are equal, print only one
            if (n/i == i)
              s.insert(i);

            else
            {
                // printf("%d %d ", i, n/i);
                s.insert(i);
                s.insert(n/i);
            }
        }
    }
}
class gfg
{

/* Function to calculate x raised to the power y */
public:
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
};
unsigned int countBits(unsigned int n)
{
   unsigned int count = 0;
   while (n)
   {
        count++;
        n >>= 1;
    }
    return count;
}
int main()
{
  ll t,n,m,i,a,b,c,j,l,r,x,u,v,y,z,k,d,nl,np,q;
  gfg g;
  cin>>n;
  ll arr[n];
  set<ll>se;
  rep(i,0,n)
  {
    cin>>arr[i];
    se.insert(arr[i]);
  }
  if(se.size()==1)
  {
    cout<<se.size()-1<<endl;
  }
  else
  {
    ll ans=0;
    for(int i=0;i<n-1;i++)
    {
        if(arr[i]<arr[i+1])
        {
            ans++;
        }
        else if(arr[i]>arr[i+1])
        {
          ans++;
        }
    }
    cout<<ans<<endl;
    vector<pair<ll,ll>>v1,v2;
    for(int i=0;i<n-1;i++)
    {
        if(arr[i]<arr[i+1])
        {
           cout<<1<<" "<<i+1<<" "<<i+2<<endl;
           // v1.pb(make_pair(i+1,i+2));
        }
        else if(arr[i]>arr[i+1])
        {
            cout<<2<<" "<<i+2<<" "<<i+1<<endl;
           // v2.pb(make_pair(i+1,i+2));
        }
    }
    // for(int i=v1.size()-1;i>=0;i--)
    // {
    //     cout<<1<<" "<<v1[i].ff<<" "<<v1[i].ss<<endl;
    // }
    // for(int i=0;i<v2.size();i++)
    // {
    //     cout<<1<<" "<<v2[i].ss<<" "<<v2[i].ff<<endl;
    // }

  }

}


#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define fin for(i=0;i<n;i++)
#define fjn for(j=0;j<n;j++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
#define getline(cin,s) get
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define ef else if
#define SORT(A) sort(A.begin(), A.end());
#define modu 998244353
#define sz(x)   (int)x.size()
#define REVERSE(A) reverse(A.begin(), A.end());
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
bool cmp(string a,string b)
{
    return sz(a)<sz(b);
}
ll myXOR(ll x, ll y)
{
  return (x|y)&(~x|~y);
}
ll powerLL(ll x, ll n)
{
    ll result = 1;
    while (n) {
        if (n & 1)
            result = result * x % mod;
        n = n / 2;
        x = x * x % mod;
    }
    return result;
}
set<ll>s;
void printDivisors(ll n)
{
    for (ll i=1; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            // If divisors are equal, print only one
            if (n/i == i)
              s.insert(i);

            else
            {
                // printf("%d %d ", i, n/i);
                s.insert(i);
                s.insert(n/i);
            }
        }
    }
}
class gfg
{

/* Function to calculate x raised to the power y */
public:
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
};
unsigned int countBits(unsigned int n)
{
   unsigned int count = 0;
   while (n)
   {
        count++;
        n >>= 1;
    }
    return count;
}
int main()
{
  ll t,n,m,i,a,b,c,j,l,r,x,u,v,y,z,k,d,nl,np,q;
  gfg g;
  cin>>n;
  ll arr[n];
  set<ll>se;
  rep(i,0,n)
  {
    cin>>arr[i];
    se.insert(arr[i]);
  }
  if(se.size()==1)
  {
    cout<<se.size()-1<<endl;
  }
  else
  {
    ll ans=0;
    for(int i=0;i<n-1;i++)
    {
        if(arr[i]<arr[i+1])
        {
            ans++;
        }
        else if(arr[i]>arr[i+1])
        {
          ans++;
        }
    }
    cout<<ans<<endl;
    for(int i=0;i<n-1;i++)
    {
        if(arr[i]<arr[i+1])
        {
           cout<<1<<" "<<i+1<<" "<<i+2<<endl;
        }
        else if(arr[i]>arr[i+1])
        {
           cout<<2<<" "<<i+1<<" "<<i+2<<endl;
        }
    }

  }

}


#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define fin for(i=0;i<n;i++)
#define fjn for(j=0;j<n;j++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
#define getline(cin,s) get
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define ef else if
#define SORT(A) sort(A.begin(), A.end());
#define modu 998244353
#define sz(x)   (int)x.size()
#define REVERSE(A) reverse(A.begin(), A.end());
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
bool cmp(string a,string b)
{
    return sz(a)<sz(b);
}
ll myXOR(ll x, ll y)
{
  return (x|y)&(~x|~y);
}
ll powerLL(ll x, ll n)
{
    ll result = 1;
    while (n) {
        if (n & 1)
            result = result * x % mod;
        n = n / 2;
        x = x * x % mod;
    }
    return result;
}
set<ll>s;
void printDivisors(ll n)
{
    for (ll i=1; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            // If divisors are equal, print only one
            if (n/i == i)
              s.insert(i);

            else
            {
                // printf("%d %d ", i, n/i);
                s.insert(i);
                s.insert(n/i);
            }
        }
    }
}
class gfg
{

/* Function to calculate x raised to the power y */
public:
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
};
unsigned int countBits(unsigned int n)
{
   unsigned int count = 0;
   while (n)
   {
        count++;
        n >>= 1;
    }
    return count;
}
int main()
{
  ll t,n,m,i,a,b,c,j,l,r,x,u,v,y,z,k,d,nl,np,q;
  gfg g;
  cin>>n;
  ll arr[n];
  set<ll>se;
  rep(i,0,n)
  {
    cin>>arr[i];
    se.insert(arr[i]);
  }
  if(se.size()==1)
  {
    cout<<se.size()-1<<endl;
  }
  else
  {
    ll ans=0;
    for(int i=0;i<n-1;i++)
    {
        if(arr[i]<arr[i+1])
        {
            ans++;
        }
        else if(arr[i]>arr[i+1])
        {
          ans++;
        }
    }
    cout<<ans<<endl;
    vector<pair<ll,ll>>v1,v2;
    for(int i=0;i<n-1;i++)
    {
        if(arr[i]<arr[i+1])
        {
           // cout<<1<<" "<<i+1<<" "<<i+2<<endl;
           v1.pb(make_pair(i+1,i+2));
        }
        else if(arr[i]>arr[i+1])
        {
           // cout<<2<<" "<<i+1<<" "<<i+2<<endl;
           v2.pb(make_pair(i+1,i+2));
        }
    }
    for(int i=v1.size()-1;i>=0;i--)
    {
        cout<<1<<" "<<v1[i].ff<<" "<<v1[i].ss<<endl;
    }
    for(int i=0;i<v2.size();i++)
    {
        cout<<1<<" "<<v2[i].ss<<" "<<v2[i].ff<<endl;
    }

  }

}


#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define fin for(i=0;i<n;i++)
#define fjn for(j=0;j<n;j++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
#define getline(cin,s) get
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define ef else if
#define SORT(A) sort(A.begin(), A.end());
#define modu 998244353
#define sz(x)   (int)x.size()
#define REVERSE(A) reverse(A.begin(), A.end());
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
bool cmp(string a,string b)
{
    return sz(a)<sz(b);
}
ll myXOR(ll x, ll y)
{
  return (x|y)&(~x|~y);
}
ll powerLL(ll x, ll n)
{
    ll result = 1;
    while (n) {
        if (n & 1)
            result = result * x % mod;
        n = n / 2;
        x = x * x % mod;
    }
    return result;
}
set<ll>s;
void printDivisors(ll n)
{
    for (ll i=1; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            // If divisors are equal, print only one
            if (n/i == i)
              s.insert(i);

            else
            {
                // printf("%d %d ", i, n/i);
                s.insert(i);
                s.insert(n/i);
            }
        }
    }
}
class gfg
{

/* Function to calculate x raised to the power y */
public:
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
};
unsigned int countBits(unsigned int n)
{
   unsigned int count = 0;
   while (n)
   {
        count++;
        n >>= 1;
    }
    return count;
}
int main()
{
  ll t,n,m,i,a,b,c,j,l,r,x,u,v,y,z,k,d,nl,np,q;
  gfg g;
  cin>>n;
  ll arr[n];
  set<ll>se;
  rep(i,0,n)
  {
    cin>>arr[i];
    se.insert(arr[i]);
  }
  if(se.size()==1)
  {
    cout<<se.size()-1<<endl;
  }
  else
  {
    cout<<se.size()-1<<endl;
    if(arr[0]<arr[1])
    {
        for(int i=se.size()-1;i>=1;i--)
        {
           cout<<1<<" "<<i<<" "<<i+1<<endl;

        }
    }
    else if(arr[0]>arr[1])
    {

     for(int i=se.size()-1;i>=1;i--)
        {
           cout<<2<<" "<<i<<" "<<i+1<<endl;

        }
    }

  }

}


#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define fin for(i=0;i<n;i++)
#define fjn for(j=0;j<n;j++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
#define getline(cin,s) get
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define ef else if
#define SORT(A) sort(A.begin(), A.end());
#define modu 998244353
#define sz(x)   (int)x.size()
#define REVERSE(A) reverse(A.begin(), A.end());
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
bool cmp(string a,string b)
{
    return sz(a)<sz(b);
}
ll myXOR(ll x, ll y)
{
  return (x|y)&(~x|~y);
}
ll powerLL(ll x, ll n)
{
    ll result = 1;
    while (n) {
        if (n & 1)
            result = result * x % mod;
        n = n / 2;
        x = x * x % mod;
    }
    return result;
}
set<ll>s;
void printDivisors(ll n)
{
    for (ll i=1; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            // If divisors are equal, print only one
            if (n/i == i)
              s.insert(i);

            else
            {
                // printf("%d %d ", i, n/i);
                s.insert(i);
                s.insert(n/i);
            }
        }
    }
}
class gfg
{

/* Function to calculate x raised to the power y */
public:
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
};
unsigned int countBits(unsigned int n)
{
   unsigned int count = 0;
   while (n)
   {
        count++;
        n >>= 1;
    }
    return count;
}
int main()
{
  ll t,n,m,i,a,b,c,j,l,r,x,u,v,y,z,k,d,nl,np,q;
  gfg g;
  cin>>n;
  ll arr[n];
  set<ll>se;
  rep(i,0,n)
  {
    cin>>arr[i];
    se.insert(arr[i]);
  }
  if(se.size()==1)
  {
    cout<<se.size()-1<<endl;
  }
  else
  {
    ll ans=0;
    for(int i=0;i<n-1;i++)
    {
        if(arr[i]<arr[i+1])
        {
            ans++;
        }
        else if(arr[i]>arr[i+1])
        {
          ans++;
        }
    }
    cout<<ans<<endl;
    vector<pair<ll,ll>>v1,v2;
    for(int i=0;i<n-1;i++)
    {
        if(arr[i]<arr[i+1])
        {
           cout<<1<<" "<<i+1<<" "<<i+2<<endl;
           // v1.pb(make_pair(i+1,i+2));
        }
        else if(arr[i]>arr[i+1])
        {
            cout<<1<<" "<<i+2<<" "<<i+1<<endl;
           // v2.pb(make_pair(i+1,i+2));
        }
    }
    // for(int i=v1.size()-1;i>=0;i--)
    // {
    //     cout<<1<<" "<<v1[i].ff<<" "<<v1[i].ss<<endl;
    // }
    // for(int i=0;i<v2.size();i++)
    // {
    //     cout<<1<<" "<<v2[i].ss<<" "<<v2[i].ff<<endl;
    // }

  }

}


#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define fin for(i=0;i<n;i++)
#define fjn for(j=0;j<n;j++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
#define getline(cin,s) get
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define ef else if
#define SORT(A) sort(A.begin(), A.end());
#define modu 998244353
#define sz(x)   (int)x.size()
#define REVERSE(A) reverse(A.begin(), A.end());
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
bool cmp(string a,string b)
{
    return sz(a)<sz(b);
}
ll myXOR(ll x, ll y)
{
  return (x|y)&(~x|~y);
}
ll powerLL(ll x, ll n)
{
    ll result = 1;
    while (n) {
        if (n & 1)
            result = result * x % mod;
        n = n / 2;
        x = x * x % mod;
    }
    return result;
}
set<ll>s;
void printDivisors(ll n)
{
    for (ll i=1; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            // If divisors are equal, print only one
            if (n/i == i)
              s.insert(i);

            else
            {
                // printf("%d %d ", i, n/i);
                s.insert(i);
                s.insert(n/i);
            }
        }
    }
}
class gfg
{

/* Function to calculate x raised to the power y */
public:
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
};
unsigned int countBits(unsigned int n)
{
   unsigned int count = 0;
   while (n)
   {
        count++;
        n >>= 1;
    }
    return count;
}
int main()
{
  ll t,n,m,i,a,b,c,j,l,r,x,u,v,y,z,k,d,nl,np,q;
  gfg g;
  cin>>n;
  ll arr[n];
  set<ll>se;
  rep(i,0,n)
  {
    cin>>arr[i];
    se.insert(arr[i]);
  }
  if(se.size()==1)
  {
    cout<<se.size()-1<<endl;
  }
  else
  {
    ll ans=0;
    for(int i=0;i<n-1;i++)
    {
        if(arr[i]<arr[i+1])
        {
            ans++;
        }
        else if(arr[i]>arr[i+1])
        {
          ans++;
        }
    }
    cout<<ans<<endl;
    vector<pair<ll,ll>>v1,v2;
    for(int i=0;i<n-1;i++)
    {
        if(arr[i]<arr[i+1])
        {
           // cout<<1<<" "<<i+1<<" "<<i+2<<endl;
           v1.pb(make_pair(i+1,i+2));
        }
        else if(arr[i]>arr[i+1])
        {
           // cout<<2<<" "<<i+1<<" "<<i+2<<endl;
           v2.pb(make_pair(i+1,i+2));
        }
    }
    for(int i=v1.size()-1;i>=0;i--)
    {
        cout<<1<<" "<<v1[i].ff<<" "<<v1[i].ss<<endl;
    }
    for(int i=v2.size()-1;i>=0;i--)
    {
        cout<<2<<" "<<v2[i].ff<<" "<<v2[i].ss<<endl;
    }

  }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a[200010],v[200010],ma=-1;
	cin>>n;
	long long i,k;
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		v[a[i]]++;
		if(v[ma]<v[a[i]])ma=a[i];
	}
	printf("%lld\n",n-v[ma]);
	int j;
	for(i=1;i<=n;i++)
	if(a[i]==ma)
	{
		j=i;break;
	}
	for(i=j;i>1;i--)
	{
		if(a[i]>a[i-1])
		{
			printf("1 %lld %lld\n",i-1,i);
			a[i]=ma;
		}
		else if(a[i]<a[i-1])
		{
			printf("2 %lld %lld\n",i-1,i);
			a[i]=ma;
		}
	}
	for(i=j;i<n;i++)
	{
		if(a[i]<a[i+1])
		{
			printf("2 %lld %lld\n",i+1,i);
			a[i+1]=ma;
		}
		else if(a[i]>a[i+1])
		{
			printf("1 %lld %lld\n",i+1,i);
			a[i+1]=ma;
		}
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
using namespace std;
const int maxn=2e5+10;
int num[maxn],n,a[maxn],ma,lc,topt;
struct da{int f,l,r;}ans[maxn];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if (++num[a[i]]>ma) {ma=num[a[i]]; lc=i;}
	}
	for (int i=lc;i<n;i++)
	 if (a[i+1]>a[lc]) ans[++topt].f=2,ans[topt].l=i+1,ans[topt].r=i;
	  else if (a[i+1]<a[lc]) ans[++topt].f=1,ans[topt].l=i+1,ans[topt].r=i;
	for (int i=lc;i>1;i--)
	 if (a[i-1]>a[lc]) ans[++topt].f=2,ans[topt].l=i-1,ans[topt].r=i;
	  else if (a[i-1]<a[lc]) ans[++topt].f=1,ans[topt].l=i-1,ans[topt].r=i;
	printf("%d\n",topt);
	for (int i=1;i<=topt;i++) printf("%d %d %d\n",ans[i].f,ans[i].l,ans[i].r);
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a[200010],v[200010],ma=0;
	cin>>n;
	long long  i,k;
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		v[a[i]]++;
		if(v[ma]<v[a[i]])ma=a[i];
	}
	printf("%lld\n",n-v[ma]);
	int j;
	for(i=1;i<=n;i++)
	if(a[i]==ma)
	{
		j=i;break;
	}
	for(i=j;i>1;i--)
	{
		if(a[i]>a[i-1])
		{
			printf("1 %lld %lld\n",i-1,i);
			a[i]=ma;
		}
		else if(a[i]<a[i-1])
		{
			printf("2 %lld %lld\n",i-1,i);
			a[i]=ma;
		}
	}
	for(i=j;i<n;i++)
	{
		if(a[i]<a[i+1])
		{
			printf("2 %lld %lld\n",i+1,i);
			a[i+1]=ma;
		}
		else if(a[i]>a[i+1])
		{
			printf("1 %lld %lld\n",i+1,i);
			a[i+1]=ma;
		}
	}
	return 0;

}


#include<bits/stdc++.h>
using namespace std;
struct da{int f,l,r;}ans[200010];
int main()
{
	int n,a[200010],v[200010],ma=-1;
	cin>>n;
	int i,k,j,topt,lc;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		v[a[i]]++;
		if(ma<v[a[i]])ma=v[a[i]],lc=i;
	}
		for (int i=lc;i<n;i++)
	 if (a[i+1]>a[lc]) ans[++topt].f=2,ans[topt].l=i+1,ans[topt].r=i;
	  else if (a[i+1]<a[lc]) ans[++topt].f=1,ans[topt].l=i+1,ans[topt].r=i;
	for (int i=lc;i>1;i--)
	 if (a[i-1]>a[lc]) ans[++topt].f=2,ans[topt].l=i-1,ans[topt].r=i;
	  else if (a[i-1]<a[lc]) ans[++topt].f=1,ans[topt].l=i-1,ans[topt].r=i;
	printf("%d\n",topt);
	for (int i=1;i<=topt;i++) printf("%d %d %d\n",ans[i].f,ans[i].l,ans[i].r);
/*	printf("%d\n",n-ma);
	for(i=j;i>=1;i--)
	{
		if(a[i]>a[j])
			printf("2 %d %d\n",i,i+1);
		else if(a[i]<a[j])
			printf("1 %d %d\n",i,i+1);
	}
	for(i=j;i<=n;i++)
	{
		if(a[i]<a[j])
			printf("1 %d %d\n",i,i-1);
		else if(a[i]>a[j])
			printf("2 %d %d\n",i,i-1);
	}
*/
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long a[200010],b[200010];
int main()
{
    long long n;
    cin>>n;
    for (long long i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a,a+n);
    //for (long long i=0;i<n;i++)cout<<a[i]<<" ";
    //cout<<endl;
    long long maxR=1,maxX=a[0],now=1,in=0,l=-1,r=1;
    for (long long  i=1;i<n;i++)
    {
        if (a[i]==a[i-1])now++;
        else
        {
            if (now>maxR)
            {
                now=maxR;
                maxX=a[i-1];
                in=i-1;
            }
            now=1;
        }
    }
    if (now>maxR)
    {
        maxR=now;
        maxX=a[n-1];
        in=n-1;
    }
    int j=0;
    while(b[j]!=maxX)j++;
    l=j-1;
    r=j+1;
    //cout<<maxR<<" "<<maxX<<endl;
    cout<<n-maxR<<endl;
    for (int i=l;i>=0;i--)
    {
        if (b[i]<maxX)
        {
            cout<<"1 "<<i+1<<" "<<i+2<<endl;
        }
        else if (b[i]>maxX)
        {
            cout<<"2 "<<i+1<<" "<<i+2<<endl;
        }
    }
    for (int i=r;i<n;i++)
    {
        if (b[i]<maxX)
        {
            cout<<"1 "<<i+1<<" "<<i<<endl;
        }
        else if (b[i]>maxX)
        {
            cout<<"2 "<<i+1<<" "<<i<<endl;
        }
    }
    //for (int i=0;i<n;i++)cout<<b[i]<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long a[200010],b[200010];
int main()
{
    long long n;
    cin>>n;
    for (long long i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a,a+n);
    //for (long long i=0;i<n;i++)cout<<a[i]<<" ";
    //cout<<endl;
    long long maxR=1,maxX=a[0],now=1,in=0;
    for (long long  i=1;i<n;i++)
    {
        if (a[i]==a[i-1])now++;
        else
        {
            if (now>maxR)
            {
                now=maxR;
                maxX=a[i-1];
                in=i-1;
            }
            now=1;
        }
    }
    if (now>maxR)
    {
        maxR=now;
        maxX=a[n-1];
        in=n-1;
    }
    //cout<<maxR<<" "<<maxX<<endl;
    cout<<n-maxR<<endl;
    for (int i=0;i<n;i++)
    {
        if (maxX>b[i])
        {
            cout<<"1 "<<i+1<<" ";
            if (i==0)cout<<in+1<<" "<<endl;
            else cout<<i<<" "<<endl;
            b[i]=maxX;
        }
        else if (maxX<b[i])
        {
            cout<<"2 "<<i+1<<" ";
            if (i==0)cout<<in+1<<" "<<endl;
            else cout<<i<<" "<<endl;
            b[i]=maxX;
        }
    }
    //for (int i=0;i<n;i++)cout<<b[i]<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long a[200010],b[200010];
int main()
{
    long long n;
    cin>>n;
    for (long long i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a,a+n);
    //for (long long i=0;i<n;i++)cout<<a[i]<<" ";
    //cout<<endl;
    long long maxR=1,maxX=b[0],now=1,in=0;
    for (long long  i=1;i<n;i++)
    {
        if (a[i]==a[i-1])now++;
        else
        {
            if (now>maxR)
            {
                now=maxR;
                maxX=a[i-1];
                in=i-1;
            }
            now=1;
        }
    }
    if (now>maxR)
    {
        maxR=now;
        maxX=a[n-1];
        in=n-1;
    }
    long long  j=0,l,r;
    while(b[j]!=maxX)j++;
    l=j-1;
    r=j+1;
    //cout<<maxR<<" "<<maxX<<endl;
    cout<<n-maxR<<endl;
    for (long long i=l;i>=0;i--)
    {
        if (b[i]<maxX)
        {
            cout<<"1 "<<i+1<<" "<<i+2<<endl;
        }
        else if (b[i]>maxX)
        {
            cout<<"2 "<<i+1<<" "<<i+2<<endl;
        }
    }
    for (long long  i=r;i<n;i++)
    {
        if (b[i]<maxX)
        {
            cout<<"1 "<<i+1<<" "<<i<<endl;
        }
        else if (b[i]>maxX)
        {
            cout<<"2 "<<i+1<<" "<<i<<endl;
        }
    }
    //for (int i=0;i<n;i++)cout<<b[i]<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long a[200010],b[200010];
int main()
{
    long long n;
    cin>>n;
    for (long long i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a,a+n);
    //for (long long i=0;i<n;i++)cout<<a[i]<<" ";
    //cout<<endl;
    long long maxR=1,maxX=a[0],now=1,in=0;
    for (long long  i=1;i<n;i++)
    {
        if (a[i]==a[i-1])now++;
        else
        {
            if (now>maxR)
            {
                maxR=now;
                maxX=a[i-1];
            }
            now=1;
        }
    }
    if (now>maxR)
    {
        maxR=now;
        maxX=a[n-1];
    }
    long long  j=0,l,r;
    while(b[j]!=maxX)j++;
    l=j-1;
    r=j+1;
    //cout<<maxR<<" "<<maxX<<endl;
    cout<<n-maxR<<endl;
    for (long long i=l;i>=0;i--)
    {
        if (b[i]<maxX)
        {
            cout<<"1 "<<i+1<<" "<<i+2<<endl;
        }
        else if (b[i]>maxX)
        {
            cout<<"2 "<<i+1<<" "<<i+2<<endl;
        }
    }
    for (long long  i=r;i<n;i++)
    {
        if (b[i]<maxX)
        {
            cout<<"1 "<<i+1<<" "<<i<<endl;
        }
        else if (b[i]>maxX)
        {
            cout<<"2 "<<i+1<<" "<<i<<endl;
        }
    }
    //for (int i=0;i<n;i++)cout<<b[i]<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long a[200010],b[200010];
int main()
{
    long long n;
    cin>>n;
    for (long long i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a,a+n);
    for (long long i=0;i<n;i++)cout<<a[i]<<" ";
    cout<<endl;
    long long maxR=1,maxX=a[0],now=1,in=0;
    for (long long  i=1;i<n;i++)
    {
        if (a[i]==a[i-1])now++;
        else
        {
            if (now>maxR)
            {
                now=maxR;
                maxX=a[i-1];
                in=i-1;
            }
            now=1;
        }
    }
    if (now>maxR)
    {
        maxR=now;
        maxX=a[n-1];
        in=n-1;
    }
    //cout<<maxR<<" "<<maxX<<endl;
    cout<<n-maxR<<endl;
    for (int i=0;i<n;i++)
    {
        if (maxX>b[i])
        {
            cout<<"1 "<<i+1<<" ";
            if (i==0)cout<<in+1<<endl;
            else cout<<i<<endl;
        }
        else if (maxX<b[i])
        {
            cout<<"2 "<<i+1<<" ";
            if (i==0)cout<<in+1<<endl;
            else cout<<i<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int a[200001],b[200001];
int main()
{
    int n;
    cin>>n;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a,a+n);
    int maxR=1,maxX=a[0],now=1,in=0;
    for (int i=1;i<n;i++)
    {
        if (a[i]==a[i-1])now++;
        else
        {
            if (now>maxR)
            {
                now=maxR;
                maxX=a[i-1];
                in=i-1;
            }
            now=1;
        }
    }
    if (now>maxR)
    {
        now=maxR;
        maxX=a[n-1];
        in=n-1;
    }
    int cnt=0;
    for (int i=0;i<n;i++)if (b[i]!=maxX)cnt++;
    cout<<cnt<<endl;
    for (int i=0;i<n;i++)
    {
        if (maxX>b[i])
        {
            cout<<"1 "<<i+1<<" "<<in+1<<endl;
        }
        else if (maxX<b[i])
        {
            cout<<"2 "<<i+1<<" "<<in+1<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
long long a[200001],b[200001];
int main()
{
    long long n;
    cin>>n;
    for (long long i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a,a+n);
    int maxR=1,maxX=a[0],now=1,in=0;
    for (long long  i=1;i<n;i++)
    {
        if (a[i]==a[i-1])now++;
        else
        {
            if (now>maxR)
            {
                now=maxR;
                maxX=a[i-1];
                in=i-1;
            }
            now=1;
        }
    }
    if (now>maxR)
    {
        now=maxR;
        maxX=a[n-1];
        in=n-1;
    }
    long long cnt=0;
    for (long long i=0;i<n;i++)if (b[i]!=maxX)cnt++;
    cout<<cnt<<endl;
    for (int i=0;i<n;i++)
    {
        if (maxX>b[i])
        {
            cout<<"1 "<<i+1<<" ";
            if (i==0)cout<<in+1<<endl;
            else cout<<i<<endl;
        }
        else if (maxX<b[i])
        {
            cout<<"2 "<<i+1<<" ";
            if (i==0)cout<<in+1<<endl;
            else cout<<i<<endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long a[200010],b[200010];
int main()
{
    long long n;
    cin>>n;
    for (long long i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a,a+n);
    //for (long long i=0;i<n;i++)cout<<a[i]<<" ";
    //cout<<endl;
    long long maxR=1,maxX=a[0],now=1,in=0;
    for (long long  i=1;i<n;i++)
    {
        if (a[i]==a[i-1])now++;
        else
        {
            if (now>maxR)
            {
                now=maxR;
                maxX=a[i-1];
                in=i-1;
            }
            now=1;
        }
    }
    if (now>maxR)
    {
        maxR=now;
        maxX=a[n-1];
        in=n-1;
    }
    long long  j=0,l,r;
    while(b[j]!=maxX)j++;
    l=j-1;
    r=j+1;
    //cout<<maxR<<" "<<maxX<<endl;
    cout<<n-maxR<<endl;
    for (long long i=l;i>=0;i--)
    {
        if (b[i]<maxX)
        {
            cout<<"1 "<<i+1<<" "<<i+2<<endl;
        }
        else if (b[i]>maxX)
        {
            cout<<"2 "<<i+1<<" "<<i+2<<endl;
        }
    }
    for (long long  i=r;i<n;i++)
    {
        if (b[i]<maxX)
        {
            cout<<"1 "<<i+1<<" "<<i<<endl;
        }
        else if (b[i]>maxX)
        {
            cout<<"2 "<<i+1<<" "<<i<<endl;
        }
    }
    //for (int i=0;i<n;i++)cout<<b[i]<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,k,l,n,m,a[200009],diff[200009],start=-1,finish=-1,c=0,cmax=0;

    cin >> n;
    for(i=1;i<=n;i++) cin >> a[i];
    for(i=1;i<n;i++)
    {
        diff[i]=a[i+1]-a[i];
        if(diff[i]==0)
        {
            c++;
            if(c>=cmax)
            {
                cmax=c;
                finish=i;
                start=finish-c+1;
            }
        }
        else
            c=0;
    }
    int ans;
    if(start==-1)
    {
        m=a[n];
        start=n;
        finish=n;
        ans=n-1;
    }
    else {m=a[start];
    ans=start-1+n-finish-1;}
    cout << ans << endl;
    for(i=start-1;i>0;i--)
    {
        if(a[i]>m)
        {
            cout << 2 << ' ' << i << ' ' << i+1 << endl;
        }
        else cout << 1 << ' ' << i << ' ' << i+1 << endl;
     }
     for(i=finish+2;i<n;i++)
     {
          if(a[i]>m)
        {
            cout << 2 << ' ' << i+1 << ' ' << i << endl;
        }
        else cout << 1 << ' ' << i+1 << ' ' << i << endl;

     }
     return 0;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,k,l,n,m,a[200009],diff[200009],start=-1,finish=-1,c=0,cmax=0;

    cin >> n;
    for(i=1;i<=n;i++) cin >> a[i];
    for(i=1;i<n;i++)
    {
        diff[i]=a[i+1]-a[i];
        if(diff[i]==0)
        {
            c++;
            if(c>=cmax)
            {
                cmax=c;
                finish=i;
                start=finish-c+1;
            }
        }
        else
            c=0;
    }
    int ans;
    if(start==-1)
    {
        m=a[n];
        start=n;
        finish=n;
        ans=n-1;
    }
    else {m=a[start];
    ans=start-1+n-finish-1;}
    cout << ans << endl;
    for(i=start-1;i>0;i--)
    {
        if(a[i]>m)
        {
            cout << 2 << ' ' << i << ' ' << i+1 << endl;
        }
        else cout << 1 << ' ' << i << ' ' << i+1 << endl;
     }
     for(i=finish+1;i<n;i++)
     {
          if(a[i]>m)
        {
            cout << 2 << ' ' << i << ' ' << i+1 << endl;
        }
        else cout << 1 << ' ' << i << ' ' << i+1 << endl;

     }
     return 0;

}


#include<bits/stdc++.h>
using namespace std;
int cnt[200009];
int main()
{
    int i,j,k,l,n,m,mx=0,a[200009];
    cin >> n;
    mx=-1;
    for(i=1;i<=n;i++)
    {
        cin >> a[i];
        cnt[a[i]]++;
        if(cnt[a[i]]>mx)
        {
            mx=cnt[a[i]];
            m=a[i];
        }

    }
    int ans=n-mx;
    int start=1;
    for(i=1;i<n;i++)
    {
        if(a[i]==m)
        {
            start=i;
            break;
        }
    }
    cout << ans << endl;
    for(i=start-1;i>=1;i--)
    {
        if(a[i]==m) continue;
        else if(a[i]>m)
        {
            cout << 2 << ' ' << i << ' ' << i+1 << endl;
        }
        else
        {
            cout << 1 << ' ' << i << ' ' << i+1 << endl;
        }
    }
    for(i=start+1;i<=n;i++)
    {
        if(a[i]==m) continue;
        else if(a[i]>m)
            cout << 2 << ' ' << i << ' ' << i-1 << endl;
        else cout << 1 << ' ' << i << ' ' << i-1 << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int cnt[200009];
int main()
{
    int i,j,k,l,n,m,mx=0,a[200009];
    cin >> n;
    mx=-1;
    for(i=1;i<=n;i++)
    {
        cin >> a[i];
        cnt[a[i]]++;
        if(cnt[a[i]]>mx)
        {
            mx=cnt[a[i]];
            m=a[i];
        }

    }
    int ans=n-mx;
    int start=1;
    for(i=1;i<n;i++)
    {
        if(a[i]==m)
        {
            start=i;
            break;
        }
    }
    cout << ans << endl;
    for(i=1;i<start;i++)
    {
        if(a[i]==m) continue;
        else if(a[i]>m)
        {
            cout << 2 << ' ' << i << ' ' << i+1 << endl;
        }
        else
        {
            cout << 1 << ' ' << i << ' ' << i+1 << endl;
        }
    }
    for(i=start+1;i<=n;i++)
    {
        if(a[i]==m) continue;
        else if(a[i]>m)
            cout << 2 << ' ' << i << ' ' << i-1 << endl;
        else cout << 1 << ' ' << i << ' ' << i-1 << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,k,l,n,m,a[200009],diff[200009],start=-1,finish=-1,c=0,cmax=0;

    cin >> n;
    for(i=1;i<=n;i++) cin >> a[i];
    for(i=1;i<n;i++)
    {
        diff[i]=a[i+1]-a[i];
        if(diff[i]==0)
        {
            c++;
            if(c>=cmax)
            {
                cmax=c;
                finish=i;
                start=finish-c+1;
            }
        }
        else
            c=0;
    }
    int ans;
    if(start==-1)
    {
        m=a[n];
        start=n;
        finish=n;
        ans=n-1;
    }
    else {m=a[start];
    ans=start-1+n-finish-1;}
    cout << ans << endl;
    for(i=start-1;i>0;i--)
    {
        if(a[i]==m) continue;
        if(a[i]>m)
        {
            cout << 2 << ' ' << i << ' ' << i+1 << endl;
        }
        else cout << 1 << ' ' << i << ' ' << i+1 << endl;
     }
     for(i=finish+2;i<n;i++)
     {
                 if(a[i]==m) continue;

          if(a[i]>m)
        {
            cout << 2 << ' ' << i << ' ' << i-1 << endl;
        }
        else cout << 1 << ' ' << i << ' ' << i-1 << endl;

     }
     return 0;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,k,l,n,m,a[200009],diff[200009],start=-1,finish=-1,c=0,cmax=0;

    cin >> n;
    for(i=1;i<=n;i++) cin >> a[i];
    for(i=1;i<n;i++)
    {
        diff[i]=a[i+1]-a[i];
        if(diff[i]==0)
        {
            c++;
            if(c>=cmax)
            {
                cmax=c;
                finish=i;
                start=finish-c+1;
            }
        }
        else
            c=0;
    }
    int ans=n-c-1;
    if(start==-1)
    {
        m=a[n];
        start=n;
        finish=n;
    }
    else m=a[start];
    cout << ans << endl;
    for(i=start-1;i>0;i--)
    {
        if(a[i]==m) continue;
        if(a[i]>m)
        {
            cout << 2 << ' ' << i << ' ' << i+1 << endl;
        }
        else cout << 1 << ' ' << i << ' ' << i+1 << endl;
     }
     for(i=finish+2;i<=n;i++)
     {
                 if(a[i]==m) continue;

        if(a[i]>m)
        {
            cout << 2 << ' ' << i << ' ' << i-1 << endl;
        }
        else cout << 1 << ' ' << i << ' ' << i-1 << endl;

     }
     return 0;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,k,l,n,m,a[200009],diff[200009],start=-1,finish=-1,c=0,cmax=0;

    cin >> n;
    for(i=1;i<=n;i++) cin >> a[i];
    for(i=1;i<n;i++)
    {
        diff[i]=a[i+1]-a[i];
        if(diff[i]==0)
        {
            c++;
            if(c>=cmax)
            {
                cmax=c;
                finish=i;
                start=finish-c+1;
            }
        }
        else
            c=0;
    }
    int ans;
    if(start==-1)
    {
        m=a[n];
        start=n;
        finish=n;
        ans=n-1;
    }
    else {m=a[start];
    ans=start-1+n-finish-1;}
    cout << ans << endl;
    for(i=start-1;i>0;i--)
    {
        if(a[i]>m)
        {
            cout << 2 << ' ' << i << ' ' << i+1 << endl;
        }
        else cout << 1 << ' ' << i << ' ' << i+1 << endl;
     }
     for(i=finish+2;i<n;i++)
     {
          if(a[i]>m)
        {
            cout << 2 << ' ' << i << ' ' << i+1 << endl;
        }
        else cout << 1 << ' ' << i << ' ' << i+1 << endl;

     }
     return 0;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,k,l,n,m,a[200009],diff[200009],start=-1,finish=-1,c=0,cmax=0;

    cin >> n;
    for(i=1;i<=n;i++) cin >> a[i];
    for(i=1;i<n;i++)
    {
        diff[i]=a[i+1]-a[i];
        if(diff[i]==0)
        {
            c++;
            if(c>=cmax)
            {
                cmax=c;
                finish=i;
                start=finish-c+1;
            }
        }
        else
            c=0;
    }
    int ans;
    if(start==-1)
    {
        m=a[n];
        start=n;
        finish=n;
        ans=n-1;
    }
    else {m=a[start];
    ans=start-1+n-finish-1;}
    cout << ans << endl;
    for(i=start-1;i>0;i--)
    {
        if(a[i]>m)
        {
            cout << 2 << ' ' << i << ' ' << i+1 << endl;
        }
        else cout << 1 << ' ' << i << ' ' << i+1 << endl;
     }
     for(i=finish+2;i<n;i++)
     {
          if(a[i]>m)
        {
            cout << 2 << ' ' << i << ' ' << i-1 << endl;
        }
        else cout << 1 << ' ' << i << ' ' << i-1 << endl;

     }
     return 0;

}


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

#define ll long long
typedef pair<ll,ll>pll;

int main()
{
    int t=1,pp=1;
//    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        ll arr[n],c[200003]={0};
        for(int i=0;i<n;i++){
            scanf("%I64d",&arr[i]);
            c[arr[i]]++;
        }
        ll mx=0,in=-1;
        for(int i=0;i<=200000;i++){
            if(mx<c[i]){
                mx=c[i];
                in=i;
            }
        }
        int pos;
        for(int i=0;i<n;i++)
        if(arr[i]==in){
            pos=i;
            break;
        }
//        cout <<in << " " << pos << endl;
        vector<pll>x,y;
        for(int i=pos+1;i<n;i++){
            if(arr[i]==arr[i-1]) continue;
            else if(arr[i]>arr[i-1]){
                x.push_back({i,i-1});
            }
            else{
                y.push_back({i,i-1});
            }
            arr[i]=arr[i-1];
        }
        for(int i=pos-1;i>=0;i--){
            if(arr[i]==arr[i+1]) continue;
            else if(arr[i]>arr[i+1]){
                x.push_back({i,i+1});
            }
            else{
                y.push_back({i,i+1});
            }
            arr[i]=arr[i+1];
        }
        printf("%d\n",x.size()+y.size());
        for(int i=0;i<x.size();i++){
            printf("2 %I64d %I64d\n",x[i].first+1,x[i].second+1);
        }

        for(int i=0;i<y.size();i++){
            printf("1 %I64d %I64d\n",y[i].first+1,y[i].second+1);
        }
    }
    return 0;
}


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

#define ll long long
typedef pair<ll,ll>pll;

int main()
{
    int t=1,pp=1;
//    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        ll arr[n],c[200003]={0};
        for(int i=0;i<n;i++){
            scanf("%I64d",&arr[i]);
            c[arr[i]]++;
        }
        ll mx=0,in=-1;
        for(int i=0;i<=200000;i++){
            if(mx<c[i]){
                mx=c[i];
                in=i;
            }
        }
        int pos;
        for(int i=0;i<n;i++)
        if(arr[i]==in){
            pos=i;
            break;
        }
//        cout <<in << " " << pos << endl;
        vector<pll>x,y;
        for(int i=pos+1;i<n;i++){
            if(arr[i]==arr[i-1]) continue;
            else if(arr[i]>arr[i-1]){
                x.push_back({i+1,i});
            }
            else{
                y.push_back({i+1,i});
            }
        }
        for(int i=pos-1;i>=0;i--){
            if(arr[i]==arr[i+1]) continue;
            else if(arr[i]>arr[i+1]){
                x.push_back({i+1,i+2});
            }
            else{
                y.push_back({i+1,i+2});
            }
        }
        printf("%d\n",x.size()+y.size());
        for(int i=0;i<x.size();i++){
            printf("2 %I64d %I64d\n",x[i].first,x[i].second);
        }

        for(int i=0;i<y.size();i++){
            printf("1 %I64d %I64d\n",y[i].first,y[i].second);
        }
    }
    return 0;
}


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

#define ll long long
typedef pair<ll,ll>pll;

int main()
{
    int t=1,pp=1;
//    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        ll arr[n],c[200003]={0};
        for(int i=0;i<n;i++){
            scanf("%I64d",&arr[i]);
            c[arr[i]]++;
        }
        ll mx=0,in=-1;
        for(int i=0;i<=200000;i++){
            if(mx<c[i]){
                mx=c[i];
                in=i;
            }
        }
        int pos;
        for(int i=0;i<n;i++)
        if(arr[i]==in){
            pos=i;
            break;
        }
//        cout <<in << " " << pos << endl;
        vector<pll>x,y;
        for(int i=pos+1;i<n;i++){
            if(arr[i]==arr[i-1]) continue;
            else if(arr[i]>arr[i-1]){
                x.push_back({i+1,i});
            }
            else{
                y.push_back({i+1,i});
            }
            arr[i]=arr[i-1];
        }
        for(int i=n-2;i>=0;i--){
            if(arr[i]==arr[i+1]) continue;
            else if(arr[i]>arr[i+1]){
                x.push_back({i+1,i+2});
            }
            else{
                y.push_back({i+1,i+2});
            }
            arr[i]=arr[i+1];
        }
        printf("%d\n",x.size()+y.size());
        for(int i=0;i<x.size();i++){
            printf("2 %I64d %I64d\n",x[i].first,x[i].second);
        }

        for(int i=0;i<y.size();i++){
            printf("1 %I64d %I64d\n",y[i].first,y[i].second);
        }
    }
    return 0;
}


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

#define ll long long
typedef pair<ll,ll>pll;

int main()
{
    int t=1,pp=1;
//    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        ll arr[n],c[200003]={0};
        for(int i=0;i<n;i++){
            scanf("%I64d",&arr[i]);
            c[arr[i]]++;
        }
        ll mx=0,in=-1;
        for(int i=0;i<=200000;i++){
            if(mx<c[i]){
                mx=c[i];
                in=i;
            }
        }
        int pos;
        for(int i=0;i<n;i++)
        if(arr[i]==in){
            pos=i;
            break;
        }
        cout << n-mx << endl;
        vector<pll>x,y;

        for(int i=pos-1;i>=0;i--){
            if(arr[i]==arr[i+1]) continue;
            else if(arr[i]>arr[i+1]){
                cout << "2 " << i+1 << " " << i+2 << endl;
            }
            else{
                cout << "1 " << i+1 << " " << i+2 << endl;
            }
            arr[i]=arr[i+1];
        }
        for(int i=0;i<n-1;i++){
            if(arr[i+1]!=in){
                if(arr[i+1]>arr[i]){
                cout << "2 " << i+2 << " " << i+1 << endl;
                }
                else{
                    cout << "1 " << i+2 << " " << i+1 << endl;
                }
                arr[i+1]=arr[i];
            }
        }
    }
    return 0;
}


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

#define ll long long
typedef pair<ll,ll>pll;

int main()
{
    int t=1,pp=1;
//    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        ll arr[n],c[200003]={0};
        for(int i=0;i<n;i++){
            scanf("%I64d",&arr[i]);
            c[arr[i]]++;
        }
        int mx=0,in=-1;
        for(int i=0;i<=200000;i++){
            if(mx<c[i]){
                mx=c[i];
                in=i;
            }
        }
        int pos;
        for(int i=0;i<n;i++)
        if(arr[i]==in){
            pos=i;
            break;
        }
//        cout <<in << " " << pos << endl;
        vector<pll>x,y;
        for(int i=0;i<n;i++){
            if(arr[i]==in) continue;
            else if(arr[i]>in){
                x.push_back({i+1,pos+1});
            }
            else{
                y.push_back({i+1,pos+1});
            }
        }
        printf("%d\n",x.size()+y.size());
        for(int i=0;i<x.size();i++){
            printf("2 %I64d %I64d\n",x[i].first,x[i].second);
        }

        for(int i=0;i<y.size();i++){
            printf("1 %I64d %I64d\n",y[i].first,y[i].second);
        }
    }
    return 0;
}


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

#define ll long long
typedef pair<ll,ll>pll;

int main()
{
    int t=1,pp=1;
//    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        ll arr[n],c[200003]={0};
        for(int i=0;i<n;i++){
            scanf("%I64d",&arr[i]);
            c[arr[i]]++;
        }
        ll mx=0,in=-1;
        for(int i=0;i<=200000;i++){
            if(mx<c[i]){
                mx=c[i];
                in=i;
            }
        }
        int pos;
        for(int i=0;i<n;i++)
        if(arr[i]==in){
            pos=i;
            break;
        }
//        cout <<in << " " << pos << endl;
        vector<pll>x,y;
        for(int i=pos+1;i<n;i++){
            if(arr[i]==arr[i-1]) continue;
            else if(arr[i]>arr[i-1]){
                x.push_back({i+1,i});
            }
            else{
                y.push_back({i+1,i});
            }
        }
        for(int i=n-2;i>=0;i--){
            if(arr[i]==arr[i+1]) continue;
            else if(arr[i]>arr[i+1]){
                x.push_back({i+1,i+2});
            }
            else{
                y.push_back({i+1,i+2});
            }
        }
        printf("%d\n",x.size()+y.size());
        for(int i=0;i<x.size();i++){
            printf("2 %I64d %I64d\n",x[i].first,x[i].second);
        }

        for(int i=0;i<y.size();i++){
            printf("1 %I64d %I64d\n",y[i].first,y[i].second);
        }
    }
    return 0;
}


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

#define ll long long
typedef pair<ll,ll>pll;

int main()
{
    int t=1,pp=1;
//    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        ll arr[n],c[200003]={0};
        for(int i=0;i<n;i++){
            scanf("%I64d",&arr[i]);
            c[arr[i]]++;
        }
        ll mx=0,in=-1;
        for(int i=0;i<=200000;i++){
            if(mx<c[i]){
                mx=c[i];
                in=i;
            }
        }
        int pos;
        for(int i=0;i<n;i++)
        if(arr[i]==in){
            pos=i;
            break;
        }
//        cout <<in << " " << pos << endl;
        vector<pll>x,y;
        for(int i=pos+1;i<n;i++){
            if(arr[i]==arr[i-1]) continue;
            else if(arr[i]>arr[i-1]){
                x.push_back({i+1,i});
            }
            else{
                y.push_back({i+1,i});
            }
            arr[i]=arr[i-1];
        }
        for(int i=pos-1;i>=0;i--){
            if(arr[i]==arr[i+1]) continue;
            else if(arr[i]>arr[i+1]){
                x.push_back({i+1,i+2});
            }
            else{
                y.push_back({i+1,i+2});
            }
            arr[i]=arr[i+1];
        }
        printf("%d\n",x.size()+y.size());
        for(int i=0;i<x.size();i++){
            printf("2 %I64d %I64d\n",x[i].first,x[i].second);
        }

        for(int i=0;i<y.size();i++){
            printf("1 %I64d %I64d\n",y[i].first,y[i].second);
        }
    }
    return 0;
}


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

#define ll long long
typedef pair<ll,ll>pll;

int main()
{
    int t=1,pp=1;
//    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        ll arr[n],c[200003]={0};
        for(int i=0;i<n;i++){
            scanf("%I64d",&arr[i]);
            c[arr[i]]++;
        }
        int mx=0,in=-1;
        for(int i=0;i<=200000;i++){
            if(mx<c[i]){
                mx=c[i];
                in=i;
            }
        }
        int pos;
        for(int i=0;i<n;i++)
        if(arr[i]==in){
            pos=i;
            break;
        }
//        cout <<in << " " << pos << endl;
        vector<pll>x,y;
        for(int i=pos+1;i<n;i++){
            if(arr[i]==in) continue;
            else if(arr[i]>arr[i-1]){
                x.push_back({i+1,i});
            }
            else{
                y.push_back({i+1,i});
            }
        }
        for(int i=pos-1;i>=0;i--){
            if(arr[i]==in) continue;
            else if(arr[i]>arr[i+1]){
                x.push_back({i+1,i+2});
            }
            else{
                y.push_back({i+1,i+2});
            }
        }
        printf("%d\n",x.size()+y.size());
        for(int i=0;i<x.size();i++){
            printf("2 %I64d %I64d\n",x[i].first,x[i].second);
        }

        for(int i=0;i<y.size();i++){
            printf("1 %I64d %I64d\n",y[i].first,y[i].second);
        }
    }
    return 0;
}


/* ****amits27**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	//ll b[2*N+1];
	vector<ll>b(2*N+1,0);
	cin>>n;
	ll a[n];
	ll max=0;
	ll maxele=0;
	ll m=0;
	ll id=0;
	ll idmax=0;
	rep(i,0,n)
		{
			cin>>a[i];
			b[a[i]]++;
			if(a[i]>maxele)
			{
				maxele=a[i];
				idmax=i;
			}
			if(m<=b[a[i]])
			{
				m=b[a[i]];
				id=i;
			}
		}
	ll fid;
	if(m==1)
	fid=idmax;
	else
		fid=id;
	//cout<<"fid "<<fid<<"\n";
	ll count=(n-m);
	cout<<count<<"\n";
	for(ll i=fid;i>0;--i)
	{
		if(a[i-1] < a[i]){
			cout<<"1 "<<(i-1+1)<<" "<<(i+1)<<"\n";
			a[i-1]=a[i-1]+abs(a[i-1]-a[i]);
		}
		else if(a[i-1] > a[i]){
			cout<<"2 "<<(i+1)<<" "<<(i+1-1)<<"\n";
			a[i-1]=a[i-1]-abs(a[i-1]-a[i]);
		}
	}
	for(ll i=fid;i<n-1;++i)
	{
		if(a[i] < a[i+1]){
			cout<<"1 "<<(i+1)<<" "<<(i+2)<<"\n";
			a[i+1]=a[i+1]-abs(a[i]-a[i+1]);
		}
		else if(a[i] > a[i+1]){
			cout<<"2 "<<(i+2)<<" "<<(i+1)<<"\n";
			a[i+1]=a[i+1]+abs(a[i]-a[i+1]);
		}
	}
	return 0;
}


def gcd(a, b)
  b == 0 ? a : gcd(b, a % b)
end

n = gets.to_i
arr = gets.split(" ").map{|x| x.to_i }
g = gcd(arr[0], arr[1])
for i in 2...n do
  g = gcd(g, arr[i])
end

n = arr.max / g - n
puts n % 2 == 1 ? "Alice" : "Bob"


n = gets.to_i
a = gets.split.collect{|i| i.to_i}
g = a[0]
a.each{|i| g=g.gcd(i)}
if ((g..a.max).step(g).size-a.size).odd?
    puts "Alice"
else
    puts "Bob"
end


n = gets.to_i
a = gets.split.collect{|i| i.to_i}
g = a[0]
a.each{|i| g=g.gcd(i)}
if ((g..a.max).step(g).to_a - a).size.odd?
    puts "Alice"
else
    puts "Bob"
end


def gcd(arr)
  a, b = arr
  b.zero? ? a : gcd([b, a % b])
end

n   = gets.to_i
arr = gets.split.map(&:to_i)
g   = gcd(arr.unshift(2))
arr.each {|i| g = gcd([g, i]) }

n = arr.max / g - n
puts %w(Bob Alice)[n % 2]


def gcd(arr)
  a, b = arr
  b.zero? ? a : gcd([b, a % b])
end

n   = gets.to_i
arr = gets.split.map(&:to_i)
m   = arr.max
g   = gcd(arr.unshift(2))
(n-2).times {|i| g = gcd([g, arr[i]]) }

n = m / g - n
puts %w(Bob Alice)[n % 2]


def gcd(arr)
  a, b = arr
  b.zero? ? a : gcd(b, a % b)
end

n   = gets.to_i
arr = gets.split.map(&:to_i)
g   = gcd(arr.unshift(2))
arr.each {|i| g = gcd([g, i]) }

n = arr.max / g - n
puts %w(bob Alice)[n % 2]


count   = gets.to_i
maximum = gets.split.map(&:to_i).max

puts (maximum - count).odd? ? "Alice" : "Bob"


def gcd(arr)
  a, b = arr
  b.zero? ? a : gcd(b, a % b)
end

gets
arr = gets.split.map(&:to_i)
g   = gcd(arr.unshift(2))
arr.each {|i| g = gcd([g, i]) }

n = arr.max / g - n
puts %w(Alice Bob)[n % 2]


count   = gets.to_i
maximum = gets.split.map(&:to_i).max

puts (maximum - count).even? ? "Alice" : "Bob"


def gcd a, b
	return a if b == 0
	gcd b, a % b
end

n = gets.to_i
a = gets.split.map { |x| x.to_i }

g = a[0]
a.each do |x|
	g = gcd g, x
end

cnt = a.max / g - a.size

if cnt.odd?
	puts 'Alice'
else
	puts 'Bob'
end


from fractions import gcd
n=input()
inp=map(int,raw_input().split())

d=reduce(gcd,inp)
if (max(inp)/(d-n))%2==0:
	print "Bob"
else:
	print "Alice"


n=input()
inp=map(int,raw_input().split())
if (max(inp)-n)%2==0:
	print "Bob"
else:
	print "Alice"


from fractions import gcd
n=input()
a=map(int,raw_input().split())
d=reduce(gcd,a)
print ["Bob","Alice"][(max(a)/d-n)%2]


from fractions import gcd
n=input()
inp=map(int,raw_input().split())

d=reduce(gcd,inp)
if (max(inp)/(d-n))%2:
	print "Alice"
else:
	print "Bob"


#include <iostream>
using namespace std;
int n;
long long arr[100];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int m=0;
    for(int i=0;i<n;i++)
    {
        if(arr[i]>m)
            m=arr[i];
    }
    int left=m-n;
    if(left%2!=0)
        cout<<"Alice"<<endl;
    else
        cout<<"Bob"<<endl;
}


def gcd(a,b):
    while b:
        a,b=b,a%b
    return a
n=input()
a=sorted(map(int,raw_input().split()))
g=reduce(gcd, a)
print ["Alice","Bob"][((a[-1])/g + 1 - n) % 2]


# coding=utf-8
import math
from decimal import Decimal
from fractions import gcd

def main():
    n = int(raw_input())
    arr = [int(x) for x in raw_input().split()]
    g = arr[0]
    for x in arr:
        g = gcd(g, x)
    n = max(arr) / g - n
    print 'Alice' if n & 1 else 'Bob'

if __name__ == '__main__':
    main()


def gcd(l):
	length = len(l)
	a = l[0]
	for i in range(1, length):
		b = l[i]
		while b != 0:
			t = b
			b = a % b
			a = t
	return a

n = int(raw_input())
a = sorted(map(int, raw_input().split()))

if (max(a) / gcd(a) - n) % 2 == 1 : print 'Alice'
else: print 'Bob'


n = int(raw_input())
a = sorted(map(int, raw_input().split()))
f = True
for i in range(n):
	if a[i] % a[0] != 0:
		f = False
		break

if f:
	print a[-1] / a[0] - n

else:
	if (max(a) - n) % 2 != 0:
		print 'Alice'
	else:
		print'Bob'


n = int(raw_input())
a = map(int, raw_input().split())

if (max(a) - n) % 2 != 0:
	print 'Alice'
else:
	print'Bob'


n = int(raw_input())
a = sorted(map(int, raw_input().split()))
s = 0
f = True
for i in range(n):
	if a[i] % a[0] != 0:
		f = False
		break

if f:
	s = a[-1] / a[0] - n

else:
	s = a[-1] - n

if (max(a) - n) % 2 != 0:
	print 'Alice'
else:
	print'Bob'


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

n = input()
a = map(int, raw_input().split())
r = 1
for i in range(n):
    r = gcd(r, a[i])
if (max(a)/r - n) % 2 > 0:
    print 'Alice'
else:
    print 'Bob'


# your code goes here
def gcd(a, b):
    if b>0:
        return gcd(b, a%b)
    else:
        return a

def lcm(a, b):
    return (a*b)/gcd(a,b)
n = input()
a = map(int, raw_input().split())
r = 1
for i in range(n):
    r = lcm(r, a[i])
if (max(a)/r - n) % 2 > 0:
    print 'Alice'
else:
    print 'Bob'


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

n = input()
a = map(int, raw_input().split())
r = a[0]
for i in range(1,n):
    r = gcd(r, a[i])
if (max(a)/r - n) % 2 > 0:
    print 'Alice'
else:
    print 'Bob'


# your code goes here
n = input()
a = map(int, raw_input().split())
if (max(a) - min(a) + 1 - n) % 2 > 0:
    print 'Alice'
else:
    print 'Bob'


# your code goes here
n = input()
a = map(int, raw_input().split())
if (max(a) - n) % 2 > 0:
    print 'Alice'
else:
    print 'Bob'


def gcd(a, b):
	a, b = abs(a), abs(b)
	a, b = a < b and (b, a) or (a, b)
	while b > 0:
		a, b = b, a % b
	return a
n,r = int(raw_input()),[int(c) for c in raw_input().split()]
x = reduce(gcd,r)
print ['Bob','Alice'][(max(r)/x-n)%2]


import sys

inp = [map(int, i.split(' ')) for i in sys.stdin.read().strip().splitlines()]

num = inp[1]

num.sort()

def find_gcd(a, b):
    if a == 0 or a == b:
        return b
    if b == 0:
        return a
    elif a > b:
        return find_gcd(a % b, b)
    elif a < b:
        return find_gcd(b % a, a)

gcd = reduce(find_gcd, num)

num = [i/gcd for i in num]

res = ['Bob', 'Alice'][(max(num)-len(num)) % 2]

sys.stdout.write(str(res))


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)
n = input()
a = map(int, raw_input().split())
g = reduce(gcd, sorted(a))
if (max(a) / g - n) & 1 == 1:
    print 'Alice'
else:
    print 'Bob'


n = input()
a = map(int,raw_input().split())

def gcd(x,y):
    return x if not y else gcd(y,x%y)

d = reduce(gcd,a)
print ['Bob','Alice'][(max(a)/d - n) % 2]


from sys import stdin
a = set()
def gcd(a,b):
 while a%b:
  t=a%b;a=b;b=t;
 return b;
b = int(stdin.readline())
c = stdin.readline().strip().split()
hi = -2

for i in c:
 x = int(i)
 if x>hi:
  hi = x
 a.add(x)
g = hi
for i in a:
 g = gcd(g,i)
ans = hi/g - len(a)
if ans%2==0:
 print "Bob"
else:
 print "Alice"


from sys import stdin
a = set()
def gcd(a,b):
 while a%b:
  t=a%b;a=b;b=t;
 return b;
b = int(stdin.readline())
c = stdin.readline().strip().split()
hi = -2

for i in c:
 x = int(i)
 if x>hi:
  hi = x
 a.add(x)
g = hi
for i in a:
 g = gcd(g,i)
ans = hi/g - len(a)
if ans%2==0:
 print "Bob"
else print "Alice"


from fractions import gcd
n=input()
a=map(int,raw_input().split())
d=reduce(gcd,a)
print ["Bob","Alice"][(max(a)/d-n)%2]


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

n = int(raw_input())
a = map(int, raw_input().split())
g = a[0]
for x in a:
	g = gcd(g, x)
m = max(a)
print ('Bob', 'Alice')[(m / g - n) % 2]


n = int(raw_input())
a = map(int, raw_input().split())
a.sort()
b = a[:]
while len(b) > 1:
    c = set()
    for t in b[:-1]:
        if t % b[-1]:
            c.add(t % b[-1])
        c.add(t)
    c = list(c)
    c.sort()
    b = c
print "Alice" if (max(a) / b[0] - n) % 2 else "Bob"


import random
n = int(raw_input())
a = map(int, raw_input().split())
a.sort()
s = a[-1]
while max(a) != min(a):
    a[-1] = a[-1] % a[0]
    if a[-1] == 0: a.pop()
    a.sort()
print "Alice" if (s / a[0] - n) % 2 else "Bob"


n = int(raw_input())
a = map(int, raw_input().split())
a.sort()
b = a[:]
while len(b) > 1:
    c = set()
    for t in b[:-1]:
        if b[-1] % t:
            c.add(b[-1] % t)
        c.add(t)
    c = list(c)
    c.sort()
    b = c[:]
print "Alice" if (max(a) / b[0] - n) % 2 else "Bob"


#import sys

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

n = int(raw_input())
nums = map(int,raw_input().split())
g = reduce(gcd, nums)
print 'Bob' if (max(nums) / g - n) % 2 == 0 else 'Alice'


import fractions
n,a=int(input()),map(int,raw_input().split(" "))
d=reduce(fractions.gcd,a)
if((max(a)/d-n)%2==0):
	print "Bob"
else:
	print "Alice"