#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
	int n;
	cin>>n;
	vector<int> arr(n);
	double tot;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		tot += arr[i];
	}

	vector<vector<int>> ans(n+1);
	double sum,this_avg,other_avg;
	for(int i=0;i<n;i++)
	{
		sum = 0;
		for(int j=i;j<n;j++)
		{
			sum += arr[j];
			this_avg = sum/(j-i+1);
			int sz = n-j+i-1;
			other_avg = (sz>0)? (tot-sum)/sz:0;
			if(this_avg > other_avg)
			{
				ans[i+1].push_back(j+1);
			}
		}
	}

	long cnt=0;
	for(int i=1;i<=n;i++)
	cnt += ans[i].size();

	cout<<cnt<<"\n";
	for(int i=1;i<=n;i++)
	{
		int sz = ans[i].size();
		for(int j=0;j<sz;j++)
		{
			cout<<i<<" "<<ans[i][j]<<"\n";
		}
	}

}
Language: C++