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# (.NET Core 3.1.201) (judge verdict: Runtime Error)

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace AtCoder.D
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var a = ReadLongs();

            var max = a.Max();
            var min = a.Min();

            var l = new List<AddInfo>();
            // すべて非負の場合
            if (max >= 0 && min >= 0)
            {
                l = GetAllPlus(a).ToList();
            }
            // すべて非正の場合
            else if (max <= 0 && min <= 0)
            {
                l = GetAllMinus(a).ToList();
            }
            // 正負混合で正の絶対値が大きい場合
            else if (Math.Abs(max) >= Math.Abs(min))
            {
                l = Get3(a).ToList();
            }
            else
            {
                l = Get4(a).ToList();
            }

            var sb = new StringBuilder();
            sb.AppendLine(l.Count.ToString());
            foreach (var item in l)
            {
                // 1-indexedに変換
                sb.AppendLine($"{item.From + 1} {item.To + 1}");
            }

            // デバッグ用
            if (true)
            {
                for (int i = 0; i < a.Count - 1; i++)
                {
                    if (a[i] > a[i + 1])
                    {
                        throw new Exception("不正解");
                    }
                }
            }

            return sb.ToString().Trim();
        }

        private static IEnumerable<AddInfo> Get4(List<long> a)
        {
            for (int i = 0; i < a.Count - 1; i++)
            {
                if (a[i] <= a[i + 1]) continue;

                if (a[i] > 0 && a[i + 1] >= 0)
                {
                    yield return new AddInfo(i, i + 1);
                    a[i + 1] += a[i];
                }
                else if (a[i] <= 0 && a[i + 1] < 0)
                {
                    yield return new AddInfo(i + 1, i);
                    a[i] += a[i + 1];
                }
                else
                {
                    // 負の絶対値が最も大きいものを取ってきて加える
                    var min = long.MaxValue;
                    var minIndex = 0;
                    for (int j = i; j < a.Count; j++)
                    {
                        if (min > a[j])
                        {
                            minIndex = j;
                            min = a[j];
                        }
                    }

                    yield return new AddInfo(minIndex, i);
                    a[i] += a[minIndex];

                    // 必要があればもう一度加える
                    if (a[i] > a[i + 1])
                    {
                        yield return new AddInfo(minIndex, i);
                        a[i] += a[minIndex];
                    }
                }
            }
        }

        private static IEnumerable<AddInfo> Get3(List<long> a)
        {
            for (int i = 0; i < a.Count - 1; i++)
            {
                if (a[i] <= a[i + 1]) continue;

                if (a[i] > 0 && a[i + 1] >= 0)
                {
                    yield return new AddInfo(i, i + 1);
                    a[i + 1] += a[i];
                }
                else if (a[i] <= 0 && a[i + 1] < 0)
                {
                    yield return new AddInfo(i + 1, i);
                    a[i] += a[i + 1];
                }
                else
                {
                    // 正の絶対値が最も大きいものを取ってきて加える
                    var max = long.MinValue;
                    var maxIndex = 0;
                    for (int j = i; j < a.Count; j++)
                    {
                        if (max < a[j])
                        {
                            maxIndex = j;
                            max = a[j];
                        }
                    }

                    yield return new AddInfo(maxIndex, i + 1);
                    a[i + 1] += a[maxIndex];

                    // 必要があればもう一度加える
                    if (a[i] > a[i + 1])
                    {
                        yield return new AddInfo(maxIndex, i + 1);
                        a[i + 1] += a[maxIndex];
                    }
                }
            }
        }

        private static IEnumerable<AddInfo> GetAllPlus(List<long> a)
        {
            for (int i = 0; i < a.Count - 1; i++)
            {
                if (a[i] <= a[i + 1]) continue;

                yield return new AddInfo(i, i + 1);
                a[i + 1] += a[i];
            }
        }
        private static IEnumerable<AddInfo> GetAllMinus(List<long> a)
        {
            for (int i = 0; i < a.Count - 1; i++)
            {
                if (a[i] <= a[i + 1]) continue;

                yield return new AddInfo(i + 1, i);
                a[i] += a[i + 1];
            }
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
    class AddInfo
    {
        public int From { get; set; }
        public int To { get; set; }

        public AddInfo(int from, int to)
        {
            From = from;
            To = to;
        }
    }
}