//Задача "Спички детям не игрушка!"
//8-я Интернет-олимпиада сезона 2008-2009, усложненный уровень
//Автор задачи: Федор Царев, tsarev@rain.ifmo.ru
//Автор решения: Максим Буздалов, buzdalov@rain.ifmo.ru

import java.io.*;
import java.util.*;

public class matches_mb {
    private static void myAssert(String msg, boolean exp) {
        if (!exp) {
            throw new AssertionError(msg);
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new FileReader("matches.in"));
        int n = Integer.parseInt(in.readLine());
        myAssert("n is out of bounds", 3 <= n && n <= 20000);
        StringTokenizer st = new StringTokenizer(in.readLine());
        int[] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = Integer.parseInt(st.nextToken());
            myAssert("a[i] is out of bounds", a[i] > 0 && a[i] <= 1000000000);
        }
        in.close();

        int[] partSums = new int[n];
        Set<Integer> partSumSet = new HashSet<Integer>();
        int sum = 0;
        int max = 0;
        for (int i = 0; i < n; ++i) {
            partSumSet.add(sum);
            partSums[i] = sum;
            sum += a[i];
            myAssert("sum is out of bounds", sum <= 1000000000);
            max = Math.max(max, a[i]);
        }

        List<Integer> divList = new ArrayList<Integer>();
        for (int i = 1; i * i <= sum; ++i) {
            int r = sum / i;
            if (r * i == sum) {
                divList.add(i);
                if (r != i) {
                    divList.add(r);
                }
            }
        }

        Collections.sort(divList);
        for (int div : divList) {
            if (div >= max) {
                for (int offsetI = 0; offsetI < n && partSums[offsetI] < div; ++offsetI) {
                    int offset = partSums[offsetI];
                    boolean isOk = true;
                    while (offset < sum) {
                        if (!partSumSet.contains(offset)) {
                            isOk = false;
                            break;
                        } else {
                            offset += div;
                        }
                    }
                    if (isOk) {
                        List<Integer> ansListL = new ArrayList<Integer>();
                        List<Integer> ansListR = new ArrayList<Integer>();
                        int newIdx = n;
                        int curOffsetI = offsetI;
                        while (curOffsetI < n && partSums[curOffsetI] + div <= sum) {
                            int last = curOffsetI;
                            int x;
                            for (x = curOffsetI + 1; x < n; ++x) {
                                if (partSums[x] - partSums[curOffsetI] < div) {
                                    ansListL.add(last);
                                    ansListR.add(x);
                                    last = newIdx++;
                                } else {
                                    break;
                                }
                            }
                            curOffsetI = x;
                        }
//                      if (offsetI > 0) {
                            int last = curOffsetI;
                            for (int i = curOffsetI + 1; i < n; ++i) {
                                ansListL.add(last);
                                ansListR.add(i);
                                last = newIdx++;
                            }
                            for (int i = 0; i < offsetI; ++i) {
                                ansListL.add(last);
                                ansListR.add(i);
                                last = newIdx++;
                            }
//                      }
                        PrintWriter out = new PrintWriter("matches.out");
                        out.println(ansListL.size());
                        for (int i = 0; i < ansListL.size(); ++i) {
                            out.println((ansListL.get(i) + 1) + " " + (ansListR.get(i) + 1));
                        }
                        out.close();
                        return;
                    }
                }
            }
        }
    }
}
