Problem:
Score : 600 points

Problem Statement

Snuke has an integer sequence, a, of length N. The i-th element of a (1-indexed) is a_{i}.

He can perform the following operation any number of times:

Operation: Choose integers x and y between 1 and N (inclusive), and add a_x to a_y.

He would like to perform this operation between 0 and 2N times (inclusive) so that a satisfies the condition below. Show one such sequence of operations.
It can be proved that such a sequence of operations always exists under the constraints in this problem.

Condition: a_1 \leq a_2 \leq ... \leq a_{N}

Constraints

2 \leq N \leq 50

-10^{6} \leq a_i \leq 10^{6}

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_{N}

Output

Let m be the number of operations in your solution. In the first line, print m.
In the i-th of the subsequent m lines, print the numbers x and y chosen in the i-th operation, with a space in between.
The output will be considered correct if m is between 0 and 2N (inclusive) and a satisfies the condition after the m operations.

Sample Input 1

3
-2 5 -1

Sample Output 1

2
2 3
3 3

After the first operation, a = (-2,5,4).

After the second operation, a = (-2,5,8), and the condition is now satisfied.

Sample Input 2

2
-1 -3

Sample Output 2

1
2 1

After the first operation, a = (-4,-3) and the condition is now satisfied.

Sample Input 3

5
0 0 0 0 0

Sample Output 3

0

The condition is satisfied already in the beginning.

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int n;
vector<long> v;

using P = pair<int,int>;

vector<P> solve(int l, int r){
  if(l+1 >= r) return {};

  bool ok = true;
  rep(i,l,r-1) if(v[i] > v[i+1]) ok = false;
  if(ok) return {};

  int mx = 0;
  int mi = -1;
  rep(i,l,r){
    if(abs(v[i]) > mx || (v[i] == -mx)){
      mx = abs(v[i]);
      mi = i;
    }
  }
  assert(mi>=0);

  if(v[mi]>0){
    auto ret = solve(l, mi);
    rep(i,mi,r) if(i < n-1){
      while(v[i] > v[i+1]){
        ret.pb(mp(i,i+1));
        v[i+1] += v[i];
      }
    }
    return ret;
  }
  else {
    auto ret = solve(mi+1, r);
    for(int i=mi; i>=l; i--) if(i > 0){
      while(v[i-1] > v[i]){
        ret.pb(mp(i, i-1));
        v[i-1] += v[i];
      }
    }
    return ret;
  }
}

int main(){
  cin>>n;
  v.resize(n);
  rep(i,n) cin>>v[i];

  auto ans = solve(0,n);
// dbg(v);
  cout << ans.size() << endl;
  for(auto &p : ans) cout << p.fi+1 << " " << p.se+1 << "\n";

  return 0;
}