#include <iostream>
#include <fstream>
using namespace std;

const int MAXN = 20000;

int n;
int a[MAXN + 1];
int id[2 * MAXN + 1];
int sum;

void Load()
{
	scanf("%d", &n);
	int i;
	sum = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		sum += a[i];
	}
	for (i = 1; i <= n; i++)
	{
		id[i] = id[n + i] = i;
	}
}

int cs[2 * MAXN + 1];
int prev[2 * MAXN + 1];
int num[2 * MAXN + 1];

int SolveSize(int sz)
{
//	cerr << "Solving size = " << sz << "\n";
	int i;
	memset(num, 0, sizeof(num));
	int ll = 0;
	for (i = 1; i <= 2 * n; i++)
	{
		int nd = cs[i] - sz;
		while (cs[ll] < nd) ll++;
//		cerr << "i = " << i << " ll = " << ll << " ";
		if (cs[ll] == nd)
		{
			prev[i] = ll;
			num[i] = num[ll] + 1;
			if (num[i] == sum / sz) 
			{
				return 1;
			}
		}
//		cerr << "num[i] = " << num[i] << "\n";
	}
	return 0;
}

void Restore(int sz)
{
	int i;
	int bi = -1;
	for (i = 1; i <= 2 * n; i++)
	{
		if (num[i] == sum / sz)
		{
			bi = i;
			break;
		}
	}
	int j;
	int tbn = n + 1;
	for (j = 0; j < sum / sz; j++)
	{
		int k;
		int pid = id[prev[bi] + 1];
		for (k = prev[bi] + 2; k <= bi; k++)
		{
			printf("%d %d\n", pid, id[k]);
			pid = tbn++;
		}
		bi = prev[bi];
	}
}

void Solve()
{
	int i;
	cs[0] = 0;
	for (i = 1; i <= n; i++)
	{
		cs[i] = cs[i - 1] + a[i - 1];
	}
	for (i = 1; i <= n; i++)
	{
		cs[i + n] = cs[i + n - 1] + a[i - 1];
	}
//	cerr << "Sums: ";
//	for (i = 0; i <= 2 * n; i++) cerr << cs[i] << " ";
//	cerr << "\n";
	int ans = n;
	int ai = -1;
	for (i = 1; i * i <= sum; i++)
	{
		if (sum % i != 0) continue;
		int k1 = SolveSize(i);
		if (k1 && (ans > n - sum / i))
		{
			ans = n - sum / i;
			ai = i;
		}
		k1 = SolveSize(sum / i);
		if (k1 && (ans > n - i))
		{
			ans = n - i;
			ai = sum / i;
		}
	}
	if (ai != -1)
	{
		SolveSize(ai);
		cout << ans << "\n";
		Restore(ai);
	}
}

int main()
{
	freopen("matches.in", "rt", stdin);
	freopen("matches.out", "wt", stdout);
	Load();
	Solve();
	return 0;
}
