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

public class matches_aa implements Runnable {

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

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	boolean eof = false;
	Random rand = new Random(this.hashCode());

	@Override
	public void run() {
		Locale.setDefault(Locale.US);
		try {
			br = new BufferedReader(new FileReader(FNAME + ".in"));
			out = new PrintWriter(FNAME + ".out");
			solve();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(566);
		}
	}

	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());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}

	BigInteger nextBigInteger() {
		return new BigInteger(nextToken());
	}

	void myAssert(boolean u, String message) {
		if (!u) {
			throw new Error("Assertion failed!!! " + message);
		}
	}

	long inBounds(long x, long l, long r, String name) {
		myAssert(l <= x && x <= r, name + " is not in bounds!!! " + x
				+ " not in [" + l + ".." + r + "]");
		return x;
	}

	int inBounds(int x, int l, int r, String name) {
		myAssert(l <= x && x <= r, name + " is not in bounds!!! " + x
				+ " not in [" + l + ".." + r + "]");
		return x;
	}

	String FNAME = "matches_aa".substring(0, "matches_aa".indexOf('_'));

	private void solve() throws IOException {
		int n = nextInt();
		long[] a = new long[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = nextInt();
		}
		for (int i = 1; i < a.length; i++) {
			a[i] = a[i] + a[i - 1];
		}
		long sum = a[a.length - 1];
		ArrayList<Long> p = new ArrayList<Long>();
		ArrayList<Integer> q = new ArrayList<Integer>();
		for (long i = 2; i * i <= sum; i++) {
			if (sum % i == 0) {
				int k = 0;
				while (sum % i == 0) {
					sum /= i;
					k++;
				}
				p.add(i);
				q.add(k);
			}
		}
		if (sum > 1) {
			p.add(sum);
			q.add(1);
		}
		ans = Long.MAX_VALUE / 2;
		d = new long[a.length];
		bf(1, 0, p, q, a);
		long size = a[a.length - 1] / (a.length - ans);
		for (int i = 0; i < a.length; i++) {
			d[i] = a[i] % size;
		}
		Arrays.sort(d);
		int max = 0;
		int k = 0;
		long it = 0;
		for (int i = 0; i < d.length; i++) {
			if (i == 0 || d[i] != d[i - 1]) {
				k = 1;
			} else {
				k++;
			}
			max = Math.max(max, k);
			if (max == a[a.length - 1] / size) {
				it = d[i];
				break;
			}
		}
		out.println(ans);
		n++;
		sum = a[a.length - 1];
		for (int i = 0; i < a.length; i++) {
			if (a[i] % size == it) {
				long cur = 0;
				boolean start = false;
				for (int j = 0; j < a.length; j++) {
					if (cur > 0) {
						if (!start) {
							out.println(n++ + " "
									+ (((i + j + 1) % a.length) + 1));
						} else {
							out.println((((i + j) % a.length) + 1) + " "
									+ (((i + j + 1) % a.length) + 1));
						}
						start = false;
					} else {
						start = true;
					}
					cur += (a[(i + j + 1) % a.length] - a[(i + j) % a.length] + sum)
							% sum;
					if (cur == size) {
						cur = 0;
						if (!start) {
							n++;
						}
					}
				}
				break;
			}
		}
	}

	long[] d;

	private void bf(long x, int j, ArrayList<Long> p, ArrayList<Integer> q,
			long[] a) {
		if (j >= p.size()) {
			for (int i = 0; i < a.length; i++) {
				d[i] = a[i] % x;
			}
			Arrays.sort(d);
			int max = 0;
			int k = 0;
			for (int i = 0; i < d.length; i++) {
				if (i == 0 || d[i] != d[i - 1]) {
					k = 1;
				} else {
					k++;
				}
				max = Math.max(max, k);
			}
			if (max >= a[a.length - 1] / x) {
				ans = Math.min(ans, a.length - a[a.length - 1] / x);
			}
			return;
		}
		bf(x, j + 1, p, q, a);
		for (int i = 0; i < q.get(j); i++) {
			x *= p.get(j);
			bf(x, j + 1, p, q, a);
		}
	}

	long ans;

}
