Language: C++

#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*int find(int a){
     if(a==par[a])return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);
     if(a==b)return ;
     par[b]=a;
}
ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
*/
int main(){
    int n;
    cin>>n;
    vector<int> a(n);rep(i,n)cin>>a[i];
    int mx=*max_element(a.begin(),a.end());
    int mn=*min_element(a.begin(),a.end());
    cout<<2*n-1<<endl;
    if(mx>=-mn){
         int id1=max_element(a.begin(),a.end())-a.begin();
         for(int i=0;i<n;i++){
              if(i!=id1)cout<<id1+1<<" "<<i+1<<endl;
         }
         for(int i=1;i<n;i++){
              cout<<i<<" "<<i+1<<endl;
         }
    }
    else{
         int id1=min_element(a.begin(),a.end())-a.begin();
         for(int i=0;i<n;i++){
              if(i!=id1)cout<<id1+1<<" "<<i+1<<endl;
         }
         for(int i=n-2;i>=0;i--)cout<<i+2<<" "<<i+1<<endl;
    }
}
 
 
 
 























#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*int find(int a){
     if(a==par[a])return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);
     if(a==b)return ;
     par[b]=a;
}
ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
*/
int main(){
    int n;
    cin>>n;
    vector<int> a(n);rep(i,n)cin>>a[i];
    int mx=*max_element(a.begin(),a.end());
    int mn=*min_element(a.begin(),a.end());
    cout<<2*n-1<<endl;
    if(mx>=-mn){
         int id1=max_element(a.begin(),a.end())-a.begin();
         for(int i=0;i<n;i++){
              if(i!=id1)cout<<id1+1<<" "<<i+1<<endl;
         }
         for(int i=1;i<n;i++){
              cout<<i<<" "<<i+1<<endl;
         }
    }
    else{
         int id1=min_element(a.begin(),a.end())-a.begin();
         for(int i=0;i<n;i++){
              if(i!=id1)cout<<id1+1<<" "<<i+1<<endl;
         }
         for(int i=n-2;i>=0;i--)cout<<i+2<<" "<<i+1<<endl;
    }
}
 
 
 
 

























Compiler output:
a.cc:138:11: error: redefinition of 'const int INF'
  138 | const int INF = (int)1e9;
      |           ^~~
a.cc:20:11: note: 'const int INF' previously defined here
   20 | const int INF = (int)1e9;
      |           ^~~
a.cc:139:10: error: redefinition of 'const long long int IINF'
  139 | const ll IINF=1LL<<62;
      |          ^~~~
a.cc:21:10: note: 'const long long int IINF' previously defined here
   21 | const ll IINF=1LL<<62;
      |          ^~~~
a.cc:140:11: error: redefinition of 'const int maxn'
  140 | const int maxn=10000005;
      |           ^~~~
a.cc:22:11: note: 'const int maxn' previously defined here
   22 | const int maxn=10000005;
      |           ^~~~
a.cc:186:5: error: redefinition of 'int main()'
  186 | int main(){
      |     ^~~~
a.cc:68:5: note: 'int main()' previously defined here
   68 | int main(){
      |     ^~~~