import java.io.BufferedOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Task {

    public static void solve() throws Exception {
	int n = nextInt();
	int[] S = new int[n];
	for(int i=0;i<n;i++) {
	    S[i] = nextInt();
	    if(i > 0) {
		S[i] += S[i-1];
	    }
	}
	Map<Integer, List<L>> map = new HashMap<>();
	for(int j=0;j<n;j++) {
	    for(int i=j;i>=0;i--) {
		int sum = S[j];
		if(i > 0) {
		    sum -= S[i-1];
		}
		L l = new L();
		l.a = i;
		l.b = j;
		List<L> list = map.get(sum);
		if(list == null) {
		    list = new ArrayList<>();
		    map.put(sum, list);
		}
		list.add(l);
	    }
	}
	List<L> longest = null;
	for(Integer sum: map.keySet()) {
	    List<L> list = map.get(sum);
	    Collections.sort(list);
	    List<L> list2 = new ArrayList<>(list.size());
	    int from = list.get(0).a;
	    for(L l: list) {
		if(l.a >= from) {
		    list2.add(l);
		    from = l.b + 1;
		}
	    }
	    if(longest == null || longest.size() < list2.size()) {
		longest = list2;
	    }
	}
	
	println(longest.size());
	for(int i=0;i<longest.size();i++) {
	    L l = longest.get(i);
	    println((l.a+1) + " " + (l.b+1));
	}
    }
    
    private static class L implements Comparable<L>{
	int a;
	int b;
	
	@Override
	public int compareTo(L l2) {
	    return Integer.valueOf(b).compareTo(l2.b);
	}
    }
    
    public static void main(String[] args) throws Exception {
	try {
	    fastReader = new FastReader(System.in);
	    systemOut = new BufferedOutputStream(System.out);
	    solve();
	} finally {
	    systemOut.close();
	}
    }

    private static FastReader fastReader = null;
    private static BufferedOutputStream systemOut = null;

    public static void print(Object obj) {
	print(obj.toString());
    }

    public static void print(String str) {
	try {
	    systemOut.write(str.getBytes("utf-8"));
	} catch (Exception ex) {
	    throw new RuntimeException(ex);
	}
    }

    public static void... Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?