#include <cstdio>
#include <algorithm>

const int MAXN = 20000;

int n, a[MAXN], al[MAXN];

int main() 
{
	freopen("matches.in", "rt", stdin);
	freopen("matches.out", "wt", stdout);
	scanf("%d", &n);
	int sum = 0;
  	for (int i = 0; i < n; ++i) 
  	{
  		scanf("%d", &a[i]);
  		sum += a[i];
  	}
    for (int i = n; i >= 1; --i) 
    {
		if (sum % i != 0) continue;
		int ts = sum / i;
		int tsum = 0;
		for (int j = 0; j < n; ++j) 
		{
			tsum = (tsum + a[j]) % ts;
			al[j] = tsum;
		}
		std::sort(al, al + n);
		int f = 0;
		for (int k = 1; k <= n; ++k) 
		{
			if (k == n || al[k - 1] != al[k]) 
			{
				if (k - f == i) 
				{
					printf("%d\n", n - i);
					tsum = 0;
					int cnt = n;
					int p = 1;
					int fnum = -2;
					for (int j = 0; j < n; ++j) 
					{
						tsum = (tsum + a[j]) % ts;
						if (tsum != al[f]) 
						{
							printf("%d %d\n", p, j + 1 < n ? j + 2 : fnum);
							p = ++cnt;
						} 
						else 
						{
							if (fnum < 0) fnum = p;
							p = j + 2;
						}
					}
					return 0;
				}
				f = k;
			}
		}
	}
	return 0;
}
