// Задача ""
// ??-ая Интернет-олимпиада сезона 2008-2009, базовый уровень
// Автор задачи: Федор Царев, tsarev@rain.ifmo.ru
// Автор решения: Сергей Поромов, poromov@rain.ifmo.ru

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

public class matches_sp_wrong implements Runnable {

	public static void main(String[] args) {
		new Thread(new matches_sp_wrong()).run();
	}

	public void run() {
		try {
			Locale.setDefault(Locale.US);
			br = new BufferedReader(new FileReader(FILENAME + ".in"));
			out = new PrintWriter(FILENAME + ".out");
			solve();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return "0";
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	void myAssert(boolean e, String s) {
		if (!e) {
			throw new Error("Assertion failure " + s);
		}
	}

	private static final String FILENAME = "matches";
	
	ArrayList<Integer> divs, divcnt;
	int[] b, c;
	int n;
	int ans;
	
	void bf(int x, int i) {
		if (x >= ans) return;
		if (i == divs.size()) {
			for (int j = 0; j < n; j++) {
				c[j] = b[j] % x;
			}
			Arrays.sort(c);
			int max = 0;
			int k = 1;
			for (int j = 1; j < n; j++) {
				if (c[j] != c[j - 1]) {
					max = Math.max(max, k);
					k = 1;
				} else {
					k++;
				}
			}
			max = Math.max(max, k);
			if (max >= b[n - 1] / x) {
				ans = Math.min(ans, x);
//				return x;
			}
			return;
		}
		for (int j = 0; j <= divcnt.get(i); j++) {
//			ans = Math.min(ans, bf(x, i + 1));
			bf(x, i + 1);
			x *= divs.get(i);
		}
	}

	public void solve() {
		n = nextInt();
		myAssert(1 <= n && n <= 20000, "Wrong n");
		int[] a = new int[n];
		b = new int[n];
		c = new int[n];
		long sum = 0;
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
			myAssert(1 <= a[i], "Wrong a");
			sum += a[i];
			b[i] = a[i];
			if (i > 0) {
				b[i] += b[i - 1];
			}
		}
		myAssert(sum <= 1e9, "Wrong sum");
		divs = new ArrayList<Integer>();
		divcnt = new ArrayList<Integer>();
		for (int i = 2; i * i <= sum; i++) {
			if (sum % i == 0) {
				divs.add(i);
				int t = 0;
				while (sum % i == 0) {
					t++;
					sum /= i;
				}
				divcnt.add(t);
			}
		}
		if (sum != 1) {
			divs.add((int)sum);
			divcnt.add(1);
		}
		ans = Integer.MAX_VALUE;
		bf(1, 0);
		int div = ans;
		int mod = 0;
		for (int i = 0; i < n; i++) {
			c[i] = b[i] % div;
		}
		Arrays.sort(c);
		int k = 1;
		int count = b[n - 1] / div;
		for (int j = 1; j < n; j++) {
			if (c[j] != c[j - 1]) {
				if (k >= count) {
					mod = c[j - 1];
				}
				k = 1;
			} else {
				k++;
			}
		}
		int[] pos = new int[count + 1];
		int m = 0;
		for (int i = 0; i < n; i++) {
			if (b[i] % div == mod) {
				pos[m++] = i;
				if (m == count) {
					break;
				}
			}
		}
		out.println(n - count);
		pos[count] = pos[0] + n;
		int nn = n;
		for (int i = 0; i < count; i++) {
			if (pos[i] + 1 < pos[i + 1]) {
				out.println(((pos[i] + 1) % n) + 1 + " " + ((pos[i] + 2) % n + 1));
				nn++;
				if ((pos[i] + 2) < pos[i + 1]) {
				for (int j = (pos[i] + 3); j <= pos[i + 1]; j = j + 1) {
					out.println((nn) + " " + (j % n + 1));
					nn++;
				}
				}
			}
		}
	}
}
