#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define INF 100000000001
#define pb emplace_back
#define frr(i,j,k) for(ll i=j; i<k; i++)
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define el <<'\n'
#define M 1000000007
#define mod 998244353
#define pii pair<ll,ll>
#define sz(x) ((int)(x).size())
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren {cout<<"NO"<<enl;}
#define rey {cout<<"YES"<<endl;}
#define mem1(a) memset(a, -1 ,sizeof(a));
#define memt(a) memset(a, true ,sizeof(a));
#define endl "\n"
#define uniq(x) x.erase(unique(all(x)),x.end());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
//---->find parent operation dsu>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ll find_par(ll u,vector<ll>&parent)
{
if(u==parent[u])return u;
return parent[u]=find_par(parent[u],parent);
}
//----------------------------------------------------------------------------------------------
//-->find union operation dsu>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void union1 (ll u,ll v,vector<ll>&parent,vector<ll>&rank)
{
u= find_par(u,parent);
v= find_par(v,parent);
if(rank[u]<rank[v])
{
parent[u]=v;
}else if(rank[v]<rank[u])
{
parent[v]=u;
}else
{
parent[v]=u;
rank[u]++;
}
}
//---------------------------------------------------------------------------------------------
//--->power function pow(2,3)like something >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ll pwr(ll a, ll b)
{
ll res = 1;
while (b > 0)
{
if (b & 1)
res = ((res * a));
//res=res;
a = (a * a);
b >>= 1;
}
return res;
}
//------------------------------------------------------------------------------------------------
//->modulo multiplication >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ll mod_mul(ll a, ll b)
{
a = a % M;
b = b % M;
return (((a * b) % M) + M) % M;
}
int ceil_div(int a, int b) { return a % b == 0 ? a / b : a / b + 1; }
//-----------------------------------------------------------------------------------------------
//->check a no is prime or not >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool isprime(ll number)
{
if (number < 2)
{
return false;
}
for (ll i = 2; i * i <= number; ++i)
{
if (number % i == 0)
{
return false;
}
}
return true;
}
//-----------------------------------------------------------------------------------------------
ll p1[1000001];
ll idx;
void SieveOfEratosthenes(ll n)
{
// Create a boolean array "prime[0..n]" and initialize
// all entries it as true. A value in prime[i] will
// finally be false if i is Not a prime, else true.
bool prime[n+1];
memset(prime, true, sizeof(prime));
for (int p=2; p*p<=n; p++)
{
// If prime[p] is not changed, then it is a prime
if (prime[p] == true)
{
// Update all multiples of p
for (int i=p*2; i<=n; i += p)
prime[i] = false;
}
}
// Print all prime numbers
for (int p=2; p<=n; p++)
{
if (prime[p])
{
idx++;
}
}
}
//-----------------------------------------------------------------------------------------------
//-> graph related calculations >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
int dx[] = {-1, 0, 0, 1};
int dy[] = {0, 1, -1, 0};
//vector<ll>ar[1000001];
// vector<ll>ar1[1000001];
//vector<pair<ll,ll>>ar[1000001];
// ll dis[10000001];
// ll dis[10000001];
//ll clr[1000001];
// ll dis[10000001];
//ull par[1000001];
//ull vis[10000001];
// ll par[1000001];
//ll vis[1000001];
//ll clr[1000001];
//-----------------------------------------------------------------------------------------------
// set<pii >::iterator it;
// vector<ll> inv, FactorialInv, Factorial;
// ll beki(ll a, ll b)
// {
// ll ret = 1 % MOD;
// a %= MOD;
// while (b)
// {
// if (b & 1LL)
// ret = ret * a % MOD;
// a = a * a % MOD;
// b >>= 1;
// }
// return ret;
// }
// void init_combination(ll MAX)
// {
// Factorial.resize(MAX + 1);
// FactorialInv.resize(MAX + 1);
// inv.resize(MAX + 1);
// Factorial[0] = 1;
// inv[0] = 1;
// for (int i = 1; i <= MAX; i++)
// {
// Factorial[i] = Factorial[i - 1] * i % MOD;
// }
// FactorialInv[MAX] = beki(Factorial[MAX], MOD - 2);
// for (ll i = MAX - 1; i >= 0; i--)
// {a
// FactorialInv[i] = FactorialInv[i + 1] * (i + 1) % MOD;
// }
// for (int i = 1; i <= MAX; i++)
// {
// inv[i] = FactorialInv[i] * Factorial[i - 1] % MOD;
// }
// }
// ll combination(ll a, ll b)
// {
// if ((a == b) || (b == 0))
// {
// return 1;
// }
// if (a < b)
// return 0;
// if (b < 0)
// return 0;
// ll = Factorial[a] * FactorialInv[b] % MOD;
// ans = ans * FactorialInv[a - b] % MOD;
// return ans;
// }
void noob()
{
ll n;
cin>>n;
vector<pair<ll,ll>>vp1,vp2,vp3;
ll cnt_neg=0;
ll cnt_zero=0;
ll cnt_pos=0;
frr(i,1,n+1)
{
ll x;cin>>x;
if(x<0){
cnt_neg++;
vp1.push_back({x,i});
}
else if(x==0){
cnt_zero++;
vp2.push_back({x,i});
}
else
{
cnt_pos++;
vp3.push_back({x,i});
}
}
sort(all(vp1));
reverse(all(vp1));
if(cnt_neg>0)
{
if(cnt_neg%2==0)
{
if(cnt_zero>0)
{
ll l1=-1;
frr(i,0,vp2.size())
{
l1= max(l1,vp2[i].ss);
}
frr(i,0,vp2.size())
{
if(vp2[i].ss!=l1)
{
cout<<"1"<<" "<<vp2[i].ss<<" "<<l1<<endl;
}
}
cout<<"2"<<" "<<l1<<endl;
}
ll k1=-1;
ll k2=-1;
frr(i,0,vp1.size())
{
k1= max(k1,vp1[i].ss);
}
frr(i,0,vp3.size())
{
k2= max(k2,vp3[i].ss);
}
ll k3= max(k1,k2);
frr(i,0,vp1.size())
{
if(vp1[i].ss!=k1)
{
cout<<"1"<<" "<<vp1[i].ss<<" "<<k1<<endl;
}
}
frr(i,0,vp3.size())
{
if(vp3[i].ss!=k2)
{
cout<<"1"<<" "<<vp3[i].ss<<" "<<k2<<endl;
}
}
if(k2!=-1)
{
ll h1= min(k1,k2);
cout<<"1"<<" "<<h1<<" "<<k3<<endl;
}
}else
{
ll l1=-1;
if(cnt_zero>0)
{
frr(i,0,vp2.size())
{
l1= max(l1,vp2[i].ss);
}
frr(i,0,vp2.size())
{
if(vp2[i].ss!=l1)
{
cout<<"1"<<" "<<vp2[i].ss<<" "<<l1<<endl;
}
}
}
if(l1>0)
{
ll k1= vp1[0].ss;
ll min1= min(l1,k1);
ll max1= max(l1,k1);
cout<<"1"<<" "<<min1<<" "<<max1<<endl;
if(vp3.size()>0|| vp1.size()>1)cout<<"2"<<" "<<max1<<endl;
}else
{
cout<<"2"<<" "<<vp1[0].ss<<endl;
}
ll k1=-1;
ll k2=-1;
frr(i,1,vp1.size())
{
k1= max(k1,vp1[i].ss);
}
frr(i,0,vp3.size())
{
k2= max(k2,vp3[i].ss);
}
ll k3= max(k1,k2);
frr(i,1,vp1.size())
{
if(vp1[i].ss!=k1)
{
cout<<"1"<<" "<<vp1[i].ss<<" "<<k1<<endl;
}
}
frr(i,0,vp3.size())
{
if(vp3[i].ss!=k2)
{
cout<<"1"<<" "<<vp3[i].ss<<" "<<k2<<endl;
}
}
if(k2!=-1&& k1!=-1)
{
ll h1= min(k1,k2);
cout<<"1"<<" "<<h1<<" "<<k3<<endl;
}
}
}else
{
ll l1=-1;
frr(i,0,vp2.size())
{
l1= max(l1,vp2[i].ss);
}
frr(i,0,vp2.size())
{
if(vp2[i].ss!=l1)
{
cout<<"1"<<" "<<vp2[i].ss<<" "<<l1<<endl;
}
}
if(l1!=-1)
{
if(vp2.size()<n)
{
cout<<"2"<<" "<<l1<<endl;
}
}
ll k1=-1;
frr(i,0,vp3.size())
{
k1= max(k1,vp3[i].ss);
}
frr(i,0,vp3.size())
{
if(vp3[i].ss!=k1)
{
cout<<"1"<<" "<<vp3[i].ss<<" "<<k1<<endl;
}
}
}
}
int main(){
ll t;
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// ll h=1;
//SieveOfEratosthenes(100001);
// cin>>t;
// while(t--){
// noob();
// }
noob();
}
1302. Deepest Leaves Sum | 1209. Remove All Adjacent Duplicates in String II |
994. Rotting Oranges | 983. Minimum Cost For Tickets |
973. K Closest Points to Origin | 969. Pancake Sorting |
967. Numbers With Same Consecutive Differences | 957. Prison Cells After N Days |
946. Validate Stack Sequences | 921. Minimum Add to Make Parentheses Valid |
881. Boats to Save People | 497. Random Point in Non-overlapping Rectangles |
528. Random Pick with Weight | 470. Implement Rand10() Using Rand7() |
866. Prime Palindrome | 1516A - Tit for Tat |
622. Design Circular Queue | 814. Binary Tree Pruning |
791. Custom Sort String | 787. Cheapest Flights Within K Stops |
779. K-th Symbol in Grammar | 701. Insert into a Binary Search Tree |
429. N-ary Tree Level Order Traversal | 739. Daily Temperatures |
647. Palindromic Substrings | 583. Delete Operation for Two Strings |
518. Coin Change 2 | 516. Longest Palindromic Subsequence |
468. Validate IP Address | 450. Delete Node in a BST |