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

public class A {
    String filename = "";

    final int INF = 1_000_000_000;
    void solve() {
        int n = readInt();
        int[] a = new int[n];
        for(int i = 0;i<n;i++){
            a[i] = readInt();
        }
        Map<Integer, Integer>[] maps = new Map[n];
        Map<Integer, Integer> sums = new HashMap();
        for(int i = 0;i<n;i++){
            maps[i] = new HashMap<>();
        }

        for(int i = 0;i<n;i++){
            int summ = 0;
            for(int j = i;j<n;j++){
                summ += a[j];
                if(!maps[i].containsKey(summ)) maps[i].put(summ, j);
                int x = sums.getOrDefault(summ, 0);
                sums.put(summ, x + 1);
            }
        }
        int max = 0;
        int goodSumm = 0;
        for(int summ : sums.keySet()){
            if(sums.get(summ) <= max) continue;
            int right = -1;
            int ans = 0;
            for(int j = 0;j<n;j++){
                if(!maps[j].containsKey(summ)) continue;
                int end = maps[j].get(summ);
                if(right == -1){
                    right = end;
                    ans++;
                    continue;
                }

                if(j > right){
                    right = end;
                    ans++;
                    continue;
                }

                if(end < right){
                    right = end;
                }
            }
            if(max < ans){
                max = ans;
                goodSumm = summ;
            }
        }
        int left = -1;
        int right = -1;
        List<Integer> ans = new ArrayList<>();
        for(int j = 0;j<n;j++){
            if(!maps[j].containsKey(goodSumm)) continue;
            int start = j;
            int end = maps[j].get(goodSumm);
            if(right == -1){
                left = j;
                right = end;
                continue;
            }

            if(start > right){
                ans.add(left + 1);
                ans.add(right + 1);
                left = start;
                right = end;
                continue;
            }

            if(end < right){
                left = start;
                right = end;
            }
        }
        ans.add(left + 1);
        ans.add(right  + 1);
        out.println(max);
        for(int i  = 0;i<ans.size();i+=2){
            out.println(ans.get(i) + " " + ans.get(i + 1));
        }
    }

    public static void main(String[] args) throws FileNotFoundException {
        new A().run();
    }
    void run() throws FileNotFoundException {
        init();
        solve();
        out.close();
    }
    BufferedReader in;
    PrintWriter out;

    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        if(!filename.equals("")) {
            in = new BufferedReader(new FileReader(new File(filename + ".in")));
            out = new PrintWriter(new File(filename + ".out"));
            return;
        }

        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

    String readLine(){
        try{
            return in.readLine();
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }

    String readString(){
        while(!tok.hasMoreTokens()){
            String nextLine = readLine();
            if(nextLine == null) return null;
            tok = new StringTokenizer(nextLine);
        }
        return tok.nextToken();
    }

    int readInt(){
        return Integer.parseInt(readString());
    }

    long readLong(){
        return Long.parseLong(readString());
    }
}


import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class F11141 {
	static class Solver {

		ArrayList<int[]> ranges[];
		HashMap<Long, Integer> hm = new HashMap<>();

		int id(long s) {
			if (!hm.containsKey(s))
				hm.put(s, hm.size());
			return hm.get(s);
		}

		// max disjoint range set in ranges[r]
		int[] memo;
		int go(int r) {
			memo[N] = 0;
			int last = N;
			for(int[] a : ranges[r]) {
				while(a[0] < last) {
					memo[last - 1] = memo[last];
					last--;
				}
				memo[a[0]] = Math.max(memo[a[0]], Math.max(memo[a[0]], 1 + memo[a[1] + 1]));
				last = a[0];
			}
			return memo[last];
		}

		ArrayDeque<int[]> ans = new ArrayDeque<>();

		void go2(int r) {
			memo[N] = 0;
			int last = N;
			int minAt[] = new int[N], oo = 987654321;
			Arrays.fill(minAt, oo);
			for(int[] a : ranges[r]) {
				minAt[a[0]] = Math.min(minAt[a[0]], a[1] - a[0]);
				while(a[0] < last) {
					memo[last - 1] = memo[last];
					last--;
				}
				memo[a[0]] = Math.max(memo[a[0]], Math.max(memo[a[0]], 1 + memo[a[1] + 1]));
				last = a[0];
			}
			while(0 < last) {
				memo[last - 1] = memo[last];
				last--;
			}
			int k = 0;
			for(; k < N;) {
				if(minAt[k] == oo || memo[k] != 1 + memo[k + minAt[k] + 1]) k++;
				else {
					ans.push(new int[] {k, k + minAt[k]});
					k += minAt[k] + 1;
				}
			}
		}

		@SuppressWarnings("unchecked")
		Solver() {
			ranges = new ArrayList[2250001];
			for (int i = 0; i < ranges.length; i++)
				ranges[i] = new ArrayList<>();
		}

		int N, LID;
		long[] a;

		void solve(Scanner s, PrintWriter out) {
			N = s.nextInt();
			a = new long[N + 1];
			for (int i = 1; i <= N; i++)
				a[i] = s.nextLong() + a[i - 1];
			for (int i = N; i >= 1; i--)
				for (int j = i; j <= N; j++) {
					int x = id(a[j] - a[i - 1]);
					ranges[x].add(new int[] { i - 1, j - 1 });
				}

			int best = 0, bid = -1;
			memo = new int[N + 1];
			Arrays.sort(ranges, (a, b) -> b.size() - a.size());
			for(int i = 0; i < ranges.length; i++, LID++) {
				if(ranges[i].size() <= best) break;
				int ans = go(i);
				if(ans > best) {
					best = ans;
					bid = i;
				}
			}

			// backtrack on bid
			out.println(best);
			go2(bid);

			while(!ans.isEmpty()) {
				int[] c = ans.pop();
				out.println(++c[0] + " " + ++c[1]);
			}

		}

	}

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		Solver solver = new Solver();
		solver.solve(s, out);

		out.close();

	}
}


import java.io.*;
import java.util.*;
import java.util.stream.*;

public class ProblemF {
    private static boolean debug = false;

    private static int N;
    private static int[] A;

    private static void solveProblem(InputStream instr) throws Exception {
        InputReader sc = new InputReader(instr);
        int testCount = 1;
        if (debug) {
            testCount = sc.nextInt();
        }

        for (int t = 1; t <= testCount; t++) {
            printDebug("------ " + t + " ------");
            N = sc.nextInt();
            A = readInts(sc, N);
            Object result = solveTestCase();
            System.out.println(result);
        }
    }

    private static Object solveTestCase() {
        int sum[] = new int[N];
        sum[0] = A[0];
        for (int i = 1; i < N; i++) {
            sum[i] = sum[i - 1] + A[i];
        }
        TreeMap<Integer, List<int[]>> map = new TreeMap<>();
        for (int i = 0; i < N; i++) {
            for (int j = i; j < N; j++) {
                int groupSum = sum[j] - (i == 0 ? 0 : sum[i - 1]);
                map.putIfAbsent(groupSum, new ArrayList<>());
                map.get(groupSum).add(new int[]{i, j});
            }
        }
        int max = -1;
        List<int[]> maxAnswer = null;
        for (Map.Entry<Integer, List<int[]>> entry : map.entrySet()) {
            List<int[]> values = entry.getValue();
            if (values.size() <= max) {
                continue;
            }
            List<int[]> curr = findMax(values);
            if (curr.size() > max) {
                max = curr.size();
                maxAnswer = curr;

            }
        }
        List<String> answer = new ArrayList<>();
        for (int[] value : maxAnswer) {
            answer.add((value[0] + 1) + " " + (value[1] + 1));
        }
        return max + "\n" + joinValues(answer, "\n");
    }

    private static List<int[]> findMax(List<int[]> values) {
        values.sort(new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[1] - o2[1];
            }
        });
        List<int[]> answer = new ArrayList<>();
        int right = -1;
        for (int i = 0; i < values.size(); i++) {
            int[] value = values.get(i);
            if (value[0] > right) {
                answer.add(value);
                right = value[1];
            }
        }
        return answer;
    }

    private static int[] readInts(InputReader sc, int N) throws Exception {
        int[] arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        return arr;
    }

    private static String joinValues(List<? extends Object> list, String delim) {
        return list.stream().map(Object::toString).collect(Collectors.joining(delim));
    }

    private static String joinValues(int[] arr, String delim) {
        List<Object> list = new ArrayList<>();
        for (Object value : arr) {
            list.add(value);
        }
        return list.stream().map(Object::toString).collect(Collectors.joining(delim));
    }

    public static void printDebug(Object str) {
        if (debug) {
            System.out.println("DEBUG: " + str);
        }
    }

    private static final class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[1024];
        private int curChar;
        private int Chars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int read() throws Exception {
            if (curChar >= Chars) {
                curChar = 0;
                Chars = stream.read(buf);
                if (Chars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public final int nextInt() throws Exception {
            return (int)nextLong();
        }

        public final long nextLong() throws Exception {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
                if (c == -1)
                    throw new IOException();
            }
            boolean negative = false;
            if (c == '-') {
                negative = true;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += (c - '0');
                c = read();
            } while (!isSpaceChar(c));
            return negative ? (-res) : (res);
        }

        public final int[] nextIntBrray(int size) throws Exception {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++)
                arr[i] = nextInt();
            return arr;
        }

        public final String next() throws Exception {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char)c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public final String nextLine() throws Exception {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char)c);
                c = read();
            } while (c != '\n' && c != -1);
            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }

    public static void main(String[] args) throws Exception {
        long currTime = System.currentTimeMillis();
        if (debug) {
            solveProblem(new FileInputStream(new File("input.in")));
            System.out.println("Time: " + (System.currentTimeMillis() - currTime));
        } else {
            solveProblem(System.in);
        }
    }

}


/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class x1141F
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         HashMap<Long, ArrayList<Integer>> map = new HashMap<Long, ArrayList<Integer>>();
         for(int r=0; r < N; r++)
         {
            long sum = 0L;
            for(int i=r; i >= 0; i--)
            {
               sum += arr[i];
               if(!map.containsKey(sum))
                  map.put(sum, new ArrayList<Integer>());
               map.get(sum).add(i);
               map.get(sum).add(r);
            }
         }
         ArrayList<Integer> res = new ArrayList<Integer>();
         for(long key: map.keySet())
         {
            ArrayList<Integer> ls = map.get(key);
            ArrayList<Integer> temp = new ArrayList<Integer>();
            temp.add(ls.get(0));
            temp.add(ls.get(1));
            int r = ls.get(1);
            for(int i=2; i < ls.size(); i+=2)
               if(r < ls.get(i))
               {
                  r = ls.get(i+1);
                  temp.add(ls.get(i));
                  temp.add(ls.get(i+1));
               }
            if(res.size() < temp.size())
               res = temp;
         }
         System.out.println(res.size()/2);
         StringBuilder sb = new StringBuilder();
         for(int i=0; i < res.size(); i+=2)
         {
            sb.append((1+res.get(i))+" "+(1+res.get(i+1)));
            sb.append("\n");
         }
         System.out.print(sb);
      }
   }


import java.util.*;
import java.util.Map.Entry;
import java.io.*;
public class Main {
	public static class node implements Comparable<node> {
		int l,r;
		node(){}
		node(int l,int r) {
			this.l=l;
			this.r=r;
		}
		@Override
		public int compareTo(node rhs) {
			return r-rhs.r;
		}
	}
	public static void main(String[] args) throws IOException {
		BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out=new PrintWriter(System.out);
		StringTokenizer sa=new StringTokenizer(in.readLine());
		int n=Integer.parseInt(sa.nextToken());
		sa=new StringTokenizer(in.readLine());
		int[] a=new int[n];
		TreeMap<Integer,ArrayList<node>> mp=new TreeMap();
		for (int i=0;i<n;++i) a[i]=Integer.parseInt(sa.nextToken());
		ArrayList<node> ans=new ArrayList<node>();
		for (int i=0;i<n;++i) {
			int tmp=0;
			for (int j=i;j<n;++j) {
				tmp+=a[j];
				if (!mp.containsKey(tmp)) {
					ArrayList<node> t=new ArrayList();
					t.add(new node(i,j));
					mp.put(tmp,t);
				} else {
					ArrayList<node> t=mp.get(tmp);
					int left=0,right=t.size()-1,res=t.size();
					while (left<=right) {
						int mid=(left+right)>>1;
						if (t.get(mid).r>=i) {
							res=mid;
							right=mid-1;
						} else left=mid+1;
					}
					if (res==t.size()) t.add(new node(i,j));
					else if (t.get(res).r>j) t.set(res,new node(i,j));
				}
				if (mp.get(tmp).size()>ans.size()) ans=mp.get(tmp);
			}
		}
		out.println(ans.size());
		for (int i=0;i<ans.size();++i)
			out.printf("%d %d\n",ans.get(i).l+1,ans.get(i).r+1);
		out.flush();
	}
}


import java.util.*;
import java.math.*;
public class Main{
	static HashMap<Integer,ArrayList<seg>> ma;
	static class seg{
		seg(int a,int b){
			l=a;r=b;
		}
		int l,r;
	}
	static int n,sum,dex;
	static int arr[]=new int[1600];
	public static void main(String argas[]){
		Scanner cin=new Scanner(System.in);
		ma=new HashMap();
		n=cin.nextInt();
		for(int i=1;i<=n;i++){
			arr[i]=cin.nextInt();
			sum=0;
			for(int j=i;j>0;j--){
				sum+=arr[j];
				if(ma.containsKey(sum)) ma.get(sum).add(new seg(j,i));
				else {
					ma.put(sum, new ArrayList<seg>());
					ma.get(sum).add(new seg(j,i));
				}
			}
		}
		int ans=0,te;
		ArrayList<seg> best=new ArrayList(),now,temp;
		Iterator it=ma.entrySet().iterator();
		while(it.hasNext()){
			now=new ArrayList();
			te=0;
			Map.Entry entry=(Map.Entry) it.next();
			temp=(ArrayList<seg>) entry.getValue();
			dex=0;
			for(int i=0;i<temp.size();i++){
				if(temp.get(i).l>dex){
					dex=temp.get(i).r;
					te++;
					now.add(new seg(temp.get(i).l,temp.get(i).r));
				}
			}
			if(te>ans){
				ans=te;
				best=now;
			}
		}
		System.out.println(ans);
		for(int i=0;i<best.size();i++){
			System.out.println(best.get(i).l+" "+best.get(i).r);
		}
	}
}


//package com.example.programming;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class Test {
    static class Pair {
        int f,s;
        public Pair(int x, int y) {f = x; s = y;}
    }
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] s = br.readLine().split(" ");
        int[] arr = new int[n];
        for(int i = 0; i<n; i++) arr[i] = Integer.parseInt(s[i]);

        HashMap<Integer, ArrayList<Pair>> map = new HashMap<>();
        for(int i = 0; i<n; i++) {
            int sum = 0;
            for(int j = i; j>=0; j--) {
                sum += arr[j];
                ArrayList<Pair> list = map.get(sum);
                if(list == null) {
                    list = new ArrayList<>();
                    map.put(sum, list);
                }
                list.add(new Pair(j, i));
            }
        }

        Iterator it = map.entrySet().iterator();
        ArrayList<Pair> ans = new ArrayList<>();
        for(;it.hasNext();){
            Map.Entry<Integer, ArrayList<Pair>> entry = (Map.Entry<Integer, ArrayList<Pair>>)it.next();
            ArrayList<Pair> list = entry.getValue();
            ArrayList<Pair> pre = new ArrayList<>();
            int r = -1;
            for(Pair p : list) {
                if(p.f > r) {
                    pre.add(p);
                    r = p.s;
                }
            }
            if(ans.size()<pre.size()) ans = pre;
        }
        StringBuilder sb = new StringBuilder();
        sb.append(ans.size()).append('\n');
        for(Pair p : ans) {
            sb.append(p.f+1).append(' ').append(p.s+1).append('\n');
        }
        System.out.print(sb);
    }

}


/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class SameSumBlocks {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();
        int[] pre = new int[N + 1];
        for (int i = 1; i <= N; i++) {
            pre[i] = pre[i - 1] + sc.nextInt();
        }
        var sumMap = new HashMap<Integer, ArrayList<Pair>>();
        for (int i = 1; i <= N; i++) {
            for (int j = i; j <= N; j++) {
                int sum = pre[j] - pre[i - 1];
                sumMap.computeIfAbsent(sum, val -> new ArrayList<>()).add(new Pair(i, j));
            }
        }
        var ans = new ArrayList<Pair>();
        for (var list : sumMap.values()) {
            Collections.sort(list, Comparator.comparingInt(p -> p.r));
            // greedily schedule the intervals
            int last = 0;
            var group = new ArrayList<Pair>();
            for (Pair p : list) {
                if (p.l > last) {
                    group.add(p);
                    last = p.r;
                }
            }
            if (group.size() > ans.size()) {
                ans = group;
            }
        }
        out.println(ans.size());
        for (Pair p : ans) {
            out.println(p);
        }
        out.close();
    }

    static class Pair {
        int l, r;
        public Pair(int ll, int rr) {
            l = ll; r = rr;
        }
        public String toString() {
            return l + " " + r;
        }
    }

    static class FastScanner {
        private int BS = 1<<16;
        private char NC = (char)0;
        private byte[] buf = new byte[BS];
        private int bId = 0, size = 0;
        private char c = NC;
        private double cnt = 1;
        private BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            }
            catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar(){
            while(bId==size) {
                try {
                    size = in.read(buf);
                }catch(Exception e) {
                    return NC;
                }
                if(size==-1)return NC;
                bId=0;
            }
            return (char)buf[bId++];
        }

        public int nextInt() {
            return (int)nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt=1;
            boolean neg = false;
            if(c==NC)c=getChar();
            for(;(c<'0' || c>'9'); c = getChar()) {
                if(c=='-')neg=true;
            }
            long res = 0;
            for(; c>='0' && c <='9'; c=getChar()) {
                res = (res<<3)+(res<<1)+c-'0';
                cnt*=10;
            }
            return neg?-res:res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c!='.' ? cur:cur+nextLong()/cnt;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while(c<=32)c=getChar();
            while(c>32) {
                res.append(c);
                c=getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while(c<=32)c=getChar();
            while(c!='\n') {
                res.append(c);
                c=getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if(c>32)return true;
            while(true) {
                c=getChar();
                if(c==NC)return false;
                else if(c>32)return true;
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.StringTokenizer;
import javafx.util.Pair;

public class Solve6 {

    public static void main(String[] args) throws IOException {
        PrintWriter pw = new PrintWriter(System.out);
        new Solve6().solve(pw);
        pw.flush();
        pw.close();
    }

    public void solve(PrintWriter pw) throws IOException {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        int[] a = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextInt();
        }
        HashMap<Integer, LinkedList<Pair<Integer, Integer>>> h = new HashMap();
        for (int i = 1; i <= n; i++) {
            int s = 0;
            for (int j = i; j >= 1; j--) {
                s += a[j];
                LinkedList<Pair<Integer, Integer>> l;
                if (!h.containsKey(s)) {
                    l = new LinkedList();
                } else {
                    l = h.get(s);
                }
                l.add(new Pair(j, i));
                h.put(s, l);
            }
        }

        int max = 0, index = 0;
        for (Map.Entry<Integer, LinkedList<Pair<Integer, Integer>>> entrySet : h.entrySet()) {
            int i = 0, size = 0;
            for (Pair<Integer, Integer> pair : entrySet.getValue()) {
                if (pair.getKey() > i) {
                    i = pair.getValue();
                    size++;
                }
            }
            if (size > max) {
                max = size;
                index = entrySet.getKey();
            }
        }
        pw.println(max);
        int i = 0;
        for (Pair<Integer, Integer> pair : h.get(index)) {
            if (pair.getKey() > i) {
                pw.println(pair.getKey() + " " + pair.getValue());
                i = pair.getValue();
            }
        }
    }

    static class FastReader {

        StringTokenizer st;
        BufferedReader br;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public boolean hasNext() throws IOException {
            String s = br.readLine();
            if (s == null || s.isEmpty()) {
                return false;
            }
            st = new StringTokenizer(s);
            return true;
        }

        public String next() throws IOException {
            if (st == null || !st.hasMoreTokens()) {
                String s = br.readLine();
                if (s.isEmpty()) {
                    return null;
                }
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }
    }
}


import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	private static class Interval implements Comparable<Interval> {
		public int start , end;
		public Interval(int start , int end) {
			this.start = start;
			this.end = end;
		}
		@Override
		public int compareTo(Interval interval) {
			return this.end - interval.end;
		}
	}

	private static int getTotal(List<Interval> list) {
		int ans = 0 , i , n = list.size();
		for (i = 0;i < n;i ++) {
			int end = list.get(i).end;
			while (i < n && list.get(i).start <= end) {
				i ++;
			}
			i --;
			ans ++;
		}
		return ans;
	}

	private static void solve(List<Interval> list) {
		List<int[]> ans = new ArrayList<>();
		int i , n = list.size();
		for (i = 0;i < n;i ++) {
			int start = list.get(i).start , end = list.get(i).end;
			while (i < n && list.get(i).start <= end) {
				i ++;
			}
			i --;
			ans.add(new int[] {start , end});
		}
		System.out.println(ans.size());
		for (int[] array : ans) {
			System.out.println(array[0] + " " + array[1]);
		}
	}

	private static long[] a = new long[2000];

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		Map<Long , List<Interval>> map = new HashMap<>();
		int i , j , n = scan.nextInt() , max = 0;
		long ans = 0;
		for (i = 1;i <= n;i ++) {
			a[i] = scan.nextLong();
		}
		for (i = 1;i <= n;i ++) {
			long sum = 0;
			for (j = i;j <= n;j ++) {
				sum += a[j];
				if (!map.containsKey(sum)) {
					map.put(sum , new ArrayList<>());
				}
				map.get(sum).add(new Interval(i , j));
			}
		}
		for (List<Interval> list : map.values()) {
			Collections.sort(list);
		}
		for (Map.Entry<Long , List<Interval>> entry : map.entrySet()) {
			int total = getTotal(entry.getValue());
			if (total > max) {
				max = total;
				ans = entry.getKey();
			}
		}
		solve(map.get(ans));

	}

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author beginner1010
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskF2 solver = new TaskF2();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskF2 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            HashMap<Integer, Integer> lastIndex = new HashMap<>();
            HashMap<Integer, Integer> maxSize = new HashMap<>();
            for (int i = 0; i < n; i++) {
                int sum = 0;
                for (int j = i; j < n; j++) {
                    sum += a[j];
                    if (maxSize.containsKey(sum) == false) {
                        maxSize.put(sum, 0);
                    }
                    int curMaxSize = maxSize.get(sum);
                    int curLastIndex = curMaxSize == 0 ? -1 : lastIndex.get(sum);
                    if (curMaxSize == 0 || curLastIndex < i) {
                        curMaxSize++;
                        curLastIndex = j;
                    } else if (curLastIndex >= j) {
                        curLastIndex = j;
                    }
                    maxSize.put(sum, curMaxSize);
                    lastIndex.put(sum, curLastIndex);
                }
            }

            int bestSum = -1;
            int bestSize = -1;
            for (int sum : maxSize.keySet()) {
                if (maxSize.get(sum) > bestSize) {
                    bestSize = maxSize.get(sum);
                    bestSum = sum;
                }
            }

            ArrayList<Interval> best = new ArrayList<>();
            lastIndex = new HashMap<>();
            maxSize = new HashMap<>();
            for (int i = 0; i < n; i++) {
                int sum = 0;
                for (int j = i; j < n; j++) {
                    sum += a[j];
                    if (sum != bestSum)
                        continue; // consider only bestSums
                    if (maxSize.containsKey(sum) == false) {
                        maxSize.put(sum, 0);
                    }
                    int curMaxSize = maxSize.get(sum);
                    int curLastIndex = curMaxSize == 0 ? -1 : lastIndex.get(sum);
                    if (curMaxSize == 0 || curLastIndex < i) {
                        curMaxSize++;
                        curLastIndex = j;
                        best.add(new Interval(i, j));
                    } else if (curLastIndex >= j) {
                        curLastIndex = j;
                        best.set(best.size() - 1, new Interval(i, j));
                    }
                    maxSize.put(sum, curMaxSize);
                    lastIndex.put(sum, curLastIndex);
                }
            }

            out.println(bestSize);
            for (Interval i : best) {
                out.println((i.l + 1) + " " + (i.r + 1));
            }
        }

        class Interval {
            int l;
            int r;

            Interval(int l, int r) {
                this.l = l;
                this.r = r;
            }

        }

    }

    static class InputReader {
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputStream stream;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isWhitespace(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isWhitespace(c));
            return res * sgn;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Set;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.Map.Entry;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskF solver = new TaskF();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskF {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }

            Map<Integer, List<Range>> rgs = new HashMap<Integer, List<Range>>();
            for (int i = 0; i < n; i++) {
                int s = 0;
                for (int j = i; j < n; j++) {
                    s += a[j];

                    if (rgs.get(s) == null) {
                        rgs.put(s, new ArrayList<Range>());
                    }

                    rgs.get(s).add(new Range(i, j));
                }
            }

            Iterator it = rgs.entrySet().iterator();

            List<Range> ans = new ArrayList<Range>();

            while (it.hasNext()) {
                Map.Entry pair = (Map.Entry) it.next();
                int sum = (int) pair.getKey();
                Object[] intermediate = ((List<Object[]>) pair.getValue()).toArray();
                Range[] ranges = new Range[intermediate.length];
                for (int i = 0; i < intermediate.length; i++) {
                    ranges[i] = (Range) intermediate[i];
                }
                Arrays.sort(ranges);

                List<Range> cand = new ArrayList<Range>();

                for (Range r : ranges) {
                    if (cand.size() == 0) {
                        cand.add(r);
                        continue;
                    }

                    if (cand.get(cand.size() - 1).j < r.i) {
                        cand.add(r);
                    } else {
                        if (cand.get(cand.size() - 1).j > r.j) {
                            cand.remove(cand.size() - 1);
                            cand.add(r);
                        }
                    }
                }

                if (cand.size() > ans.size()) {
                    ans = cand;
                }
            }

            out.println(ans.size());
            for (Range r : ans) {
                out.println((r.i + 1) + " " + (r.j + 1));
            }
        }

        public class Range implements Comparable {
            public int i;
            public int j;

            public Range(int i, int j) {
                this.i = i;
                this.j = j;
            }

            public int compareTo(Object o) {
                Range t = (Range) o;
                if (this.i == t.i) {
                    if (this.j < t.j) return 1;
                    else return 0;
                }
                if (this.i < t.i) return 1;
                return 0;
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main {
    static final long MOD = 1_000_000_007, INF = 1_000_000_000_000_000_000L;
    static final int INf = 1_000_000_000;
    static FastReader reader;
    static PrintWriter writer;
    public static void main(String[] args) {
        Thread t = new Thread(null, new O(), "Integer.MAX_VALUE", 100000000);
        t.start();
    }
    static class O implements Runnable {
        public void run() {
            try {
                magic();
            }
            catch (Exception e) {
                e.printStackTrace();
                System.exit(1);
            }
        }
    }
    static class FastReader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public FastReader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public FastReader(String file_name) throws IOException {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException {
            byte[] buf = new byte[1000000];
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n') break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg) return -ret;
            return ret;
        }

        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg) return -ret;
            return ret;
        }

        public double nextDouble() throws IOException {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (c == '.') while ((c = read()) >= '0' && c <= '9') ret += (c - '0') / (div *= 10);
            if (neg) return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1) buffer[0] = -1;
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead) fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException {
            if (din == null) return;
            din.close();
        }
    }
    static void magic() throws IOException {
        reader = new FastReader();
        writer = new PrintWriter(System.out, true);
        Map<Integer, ArrayList<Pair>> map = new HashMap<>();
        int n = reader.nextInt();
        int arr[] = new int[n];
        for(int i=0;i<n;++i) {
            arr[i] = reader.nextInt();
        }
        for(int i=0;i<n;++i) {
            int sum = 0;
            for(int j=i;j<n;++j) {
                sum+=arr[j];
                ArrayList<Pair> list = map.get(sum);
                if(list==null) {
                    list = new ArrayList<>();
                }
                list.add(new Pair(i+1,j+1));
                map.put(sum, list);
            }
        }
        int ans = 0,at = -1;
        for(int e : map.keySet()) {
            ArrayList<Pair> list = map.get(e);
            Collections.sort(list);
//            writer.println("Pairs having sum: "+e);
//            for(Pair p : list) {
//                writer.print(p);
//                writer.print(" ");
//            }
//            writer.println();
            int ispe = 0;
            int len = list.size();
            for(int i=0;i<len;++i) {
                ispe++;
                int r = list.get(i).y;
                while(i+1<len && list.get(i+1).x<=r) {
                    i++;
                }
            }
            if(ans<ispe) {
                ans = ispe;
                at = e;
            }
        }
        writer.println(ans);
        ArrayList<Pair> list = map.get(at);
        Collections.sort(list);
        int len = list.size();
        for(int i=0;i<len;++i) {
            writer.println(list.get(i).x+" "+list.get(i).y);
            int r = list.get(i).y;
            while(i+1<len && list.get(i+1).x<=r) {
                i++;
            }
        }
    }
    static class Pair implements Comparable<Pair> {
        int x,y;
        Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
        public int compareTo(Pair other) {
            if(this.y!=other.y) {
                return this.y - other.y;
            }
            return this.x - other.x;
        }
        public String toString() {
            return "{" + x + "," + y + "}";
        }
    }
}


import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class F11141 {
	static class Solver {

		ArrayList<int[]> ranges[];
		HashMap<Long, Integer> hm = new HashMap<>();

		int id(long s) {
			if (!hm.containsKey(s))
				hm.put(s, hm.size());
			return hm.get(s);
		}

		// max disjoint range set in ranges[r]
		int[] memo;
		int go(int r) {
			memo[N] = 0;
			int last = N;
			for(int[] a : ranges[r]) {
				while(a[0] < last) {
					memo[last - 1] = memo[last];
					last--;
				}
				memo[a[0]] = Math.max(memo[a[0]], Math.max(memo[a[0]], 1 + memo[a[1] + 1]));
				last = a[0];
			}
			while(0 < last) {
				memo[last - 1] = memo[last];
				last--;
			}
			return memo[0];
		}

		ArrayDeque<int[]> ans = new ArrayDeque<>();

		void go2(int r) {
			memo[N] = 0;
			int last = N;
			int minAt[] = new int[N], oo = 987654321;
			Arrays.fill(minAt, oo);
			for(int[] a : ranges[r]) {
				minAt[a[0]] = Math.min(minAt[a[0]], a[1] - a[0]);
				while(a[0] < last) {
					memo[last - 1] = memo[last];
					last--;
				}
				memo[a[0]] = Math.max(memo[a[0]], Math.max(memo[a[0]], 1 + memo[a[1] + 1]));
				last = a[0];
			}
			while(0 < last) {
				memo[last - 1] = memo[last];
				last--;
			}
			int k = 0;
			for(; k < N;) {
				if(minAt[k] == oo || memo[k] != 1 + memo[k + minAt[k] + 1]) k++;
				else {
					ans.push(new int[] {k, k + minAt[k]});
					k += minAt[k] + 1;
				}
			}
		}

		@SuppressWarnings("unchecked")
		Solver() {
			ranges = new ArrayList[2250001];
			for (int i = 0; i < ranges.length; i++)
				ranges[i] = new ArrayList<>();
		}

		int N, LID;
		long[] a;

		void solve(Scanner s, PrintWriter out) {
			N = s.nextInt();
			a = new long[N + 1];
			for (int i = 1; i <= N; i++)
				a[i] = s.nextLong() + a[i - 1];
			for (int i = N; i >= 1; i--)
				for (int j = i; j <= N; j++) {
					int x = id(a[j] - a[i - 1]);
					ranges[x].add(new int[] { i - 1, j - 1 });
				}

			int best = 0, bid = -1;
			memo = new int[N + 1];
			Arrays.sort(ranges, (a, b) -> b.size() - a.size());
			for(int i = 0; i < ranges.length; i++, LID++) {
				if(ranges[i].size() <= best) break;
				int ans = go(i);
				if(ans > best) {
					best = ans;
					bid = i;
				}
			}

			// backtrack on bid
			out.println(best);
			go2(bid);

			while(!ans.isEmpty()) {
				int[] c = ans.pop();
				out.println(++c[0] + " " + ++c[1]);
			}

		}

	}

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		Solver solver = new Solver();
		solver.solve(s, out);

		out.close();

	}
}


import java.util.*;
import java.io.*;
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
    //SOLUTION BEGIN
    //Code not meant for understanding, proceed with caution
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int n = ni();
        int[] a = new int[n];
        for(int i = 0; i< n; i++)a[i] = ni();
        HashMap<Long, ArrayList<int[]>> map = new HashMap<>();
        for(int i = 0; i< n; i++){
            long sum = 0;
            for(int j = i; j< n; j++){
                sum+=a[j];
                if(!map.containsKey(sum))map.put(sum, new ArrayList<>());
                map.get(sum).add(new int[]{i+1, j+1});
            }
        }
        int[][] ans = new int[n][];int cur = 0;
        int[][] tmp = new int[n][];int tc;
        for(Map.Entry<Long, ArrayList<int[]>> e: map.entrySet()){
            int prev = 0;
            ArrayList<int[]> li = e.getValue();
            Collections.sort(li, new Comparator<int[]>(){
                public int compare(int[] i1, int[] i2){
                    if(i1[1]!=i2[1])return Integer.compare(i1[1], i2[1]);
                    return Integer.compare(i1[0], i1[0]);
                }
            });
                tc = 0;
            for(int[] p:li){
                if(p[0]>prev){
                    tmp[tc++] = new int[]{p[0],p[1]};
                    prev = p[1];
                }
            }
            if(tc>cur){
                cur = tc;
                for(int i = 0; i< tc; i++)ans[i] = new int[]{tmp[i][0], tmp[i][1]};
            }
        }
        pn(cur);
        for(int i = 0; i< cur; i++)pn(ans[i][0]+" "+ans[i][1]);
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    long mod = (long)1e9+7, IINF = (long)1e18;
    final int INF = (int)1e9, MX = (int)2e3+1;
    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.1415926535897932384626433832792884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        //Solution Credits: Taranpreet Singh
        pre();for(int t = 1; t<= T; t++)solve(t);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next() throws Exception{
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    throw new Exception(e.toString());
                }
            }
            return st.nextToken();
        }

        String nextLine() throws Exception{
            String str = "";
            try{
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }
            return str;
        }
    }
}


import java.io.*;
import java.util.*;
import java.util.stream.*;

public class ProblemF {
    private static boolean debug = false;

    private static int N;
    private static int[] A;

    private static void solveProblem(InputStream instr) throws Exception {
        InputReader sc = new InputReader(instr);
        int testCount = 1;
        if (debug) {
            testCount = sc.nextInt();
        }

        for (int t = 1; t <= testCount; t++) {
            printDebug("------ " + t + " ------");
            N = sc.nextInt();
            A = readInts(sc, N);
            Object result = solveTestCase();
            System.out.println(result);
        }
    }

    private static Object solveTestCase() {
        int sum[] = new int[N];
        sum[0] = A[0];
        for (int i = 1; i < N; i++) {
            sum[i] = sum[i - 1] + A[i];
        }
        Map<Integer, List<int[]>> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            for (int j = i; j < N; j++) {
                int groupSum = sum[j] - (i == 0 ? 0 : sum[i - 1]);
                map.putIfAbsent(groupSum, new ArrayList<>());
                map.get(groupSum).add(new int[]{i, j});
            }
        }
        int max = -1;
        List<int[]> maxAnswer = null;
        for (Map.Entry<Integer, List<int[]>> entry : map.entrySet()) {
            List<int[]> values = entry.getValue();
            if (values.size() <= max) {
                continue;
            }
            List<int[]> curr = findMax(values);
            if (curr.size() > max) {
                max = curr.size();
                maxAnswer = curr;

            }
        }
        List<String> answer = new ArrayList<>();
        for (int[] value : maxAnswer) {
            answer.add((value[0] + 1) + " " + (value[1] + 1));
        }
        return max + "\n" + joinValues(answer, "\n");
    }

    private static List<int[]> findMax(List<int[]> values) {
        values.sort(new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[1] - o2[1];
            }
        });
        List<int[]> answer = new ArrayList<>();
        int right = -1;
        for (int i = 0; i < values.size(); i++) {
            int[] value = values.get(i);
            if (value[0] > right) {
                answer.add(value);
                right = value[1];
            }
        }
        return answer;
    }

    private static int[] readInts(InputReader sc, int N) throws Exception {
        int[] arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        return arr;
    }

    private static String joinValues(List<? extends Object> list, String delim) {
        return list.stream().map(Object::toString).collect(Collectors.joining(delim));
    }

    private static String joinValues(int[] arr, String delim) {
        List<Object> list = new ArrayList<>();
        for (Object value : arr) {
            list.add(value);
        }
        return list.stream().map(Object::toString).collect(Collectors.joining(delim));
    }

    public static void printDebug(Object str) {
        if (debug) {
            System.out.println("DEBUG: " + str);
        }
    }

    private static final class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[1024];
        private int curChar;
        private int Chars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int read() throws Exception {
            if (curChar >= Chars) {
                curChar = 0;
                Chars = stream.read(buf);
                if (Chars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public final int nextInt() throws Exception {
            return (int)nextLong();
        }

        public final long nextLong() throws Exception {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
                if (c == -1)
                    throw new IOException();
            }
            boolean negative = false;
            if (c == '-') {
                negative = true;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += (c - '0');
                c = read();
            } while (!isSpaceChar(c));
            return negative ? (-res) : (res);
        }

        public final int[] nextIntBrray(int size) throws Exception {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++)
                arr[i] = nextInt();
            return arr;
        }

        public final String next() throws Exception {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char)c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public final String nextLine() throws Exception {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char)c);
                c = read();
            } while (c != '\n' && c != -1);
            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }

    public static void main(String[] args) throws Exception {
        long currTime = System.currentTimeMillis();
        if (debug) {
            solveProblem(new FileInputStream(new File("input.in")));
            System.out.println("Time: " + (System.currentTimeMillis() - currTime));
        } else {
            solveProblem(System.in);
        }
    }

}


// Author: aman_robotics

//package math_codet;

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

public class lets_do {
    FastReader in;
    PrintWriter out;
    Helper_class h;
    final long mod = 1000000009;
    final int MAXN = 1000005;
    final int lgN = 20;
    final long INF = (long)1e18;
    final long MAX_Ai = (long)1e12;
    public static void main(String[] args) throws java.lang.Exception{
        new lets_do().run();
    }
    void run() throws Exception{
        in=new FastReader(System.in);
        out = new PrintWriter(System.out);
        h = new Helper_class();
        int t = 1;
        while(t--> 0)
            solve();
        out.flush();
        out.close();
    }
    void solve(){
        int n = h.ni();
        long[] arr = new long[n];
        int i = 0, j = 0;
        for(i = 0; i < n; i++)
            arr[i] = h.nl();
        HashMap<Long, Integer> hmap = new HashMap<Long, Integer>();
        int cnt = 0;
        for(i = 0; i < n; i++){
            long sum = 0;
            for(j = i; j < n; j++){
                sum += arr[j];
                Integer x = hmap.get(sum);
                if(x == null)
                    hmap.put(sum, cnt++);
            }
        }
        TreeSet<Pair>[] tset = new TreeSet[cnt];
        for(i = 0; i < cnt; i++)
            tset[i] = new TreeSet<Pair>(com);
        for(i = 0; i < n; i++){
            long sum = 0;
            for(j = i; j < n; j++){
                sum += arr[j];
                tset[hmap.get(sum)].add(new Pair(i, j));
            }
        }
        int max = 0;
        int ind = -1;
        int max_x = 0, max_y = 0;
        for(i = 0; i < cnt; i++){
        	int curr_y = tset[i].first().y;
        	int cnt1 = 1;
            for(Pair yo : tset[i]){
                if(yo.x > curr_y) {
                	cnt1++;
                	curr_y = yo.y;
                }
            }
            if(max < cnt1) {
            	max = cnt1;
            	ind = i;
            }
        }
        h.pn(max);
        Pair hola_yee = new Pair(tset[ind].first().x, tset[ind].first().y);
        h.pn((tset[ind].first().x + 1) +" "+(tset[ind].first().y + 1));
        int curr_y = tset[ind].first().y;
        for(Pair yo : tset[ind]){
            if(yo.x > curr_y) {
            	curr_y = yo.y;
            	h.pn((yo.x + 1) +" "+(yo.y + 1));
            }
        }
    }

    static final Comparator<Pair> com=new Comparator<Pair>(){
        public int compare(Pair a, Pair b){
            if(Integer.compare(a.y, b.y) != 0)
                return Integer.compare(a.y, b.y);
            else
                return Integer.compare(a.x, b.x);
        }
    };

    class Pair{
        int x;
        int y;
        Pair(int p, int q){
            x = p;
            y = q;
        }
    }
    class Edge{
        int u , v;
        long wt;
        Edge(int a, int b, long w){
            u = a;
            v = b;
            wt = w;
        }
        int other(int x) {
            return u ^ v ^ x;
        }
    }

    class Helper_class{
        long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
        int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
        int bitcount(long n){return (n==0)?0:(1+bitcount(n&(n-1)));}
        void p(Object o){out.print(o);}
        void pn(Object o){out.println(o);}
        void pni(Object o){out.println(o);out.flush();}
        String n(){return in.next();}
        String nln(){return in.nextLine();}
        int ni(){return Integer.parseInt(in.next());}
        long nl(){return Long.parseLong(in.next());}
        double nd(){return Double.parseDouble(in.next());}

        long mul(long a,long b){
            if(a>=mod)a%=mod;
            if(b>=mod)b%=mod;
            a*=b;
            if(a>=mod)a%=mod;
            return a;
        }
        long modPow(long a, long p){
            long o = 1;
            while(p>0){
                if((p&1)==1)o = mul(o,a);
                a = mul(a,a);
                p>>=1;
            }
            return o;
        }
        long add(long a, long b){
            if(a>=mod)a%=mod;
            if(b>=mod)b%=mod;
            if(b<0)b+=mod;
            a+=b;
            if(a>=mod)a-=mod;
            return a;
        }
    }

    class FastReader{
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int peek() {
            if (numChars == -1)
                return -1;
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    return -1;
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar];
        }

        public void skip(int x) {
            while (x-- > 0)
                read();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public String nextString() {
            return next();
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        public String nextLine() {
            StringBuffer buf = new StringBuffer();
            int c = read();
            while (c != '\n' && c != -1) {
                if (c != '\r')
                    buf.appendCodePoint(c);
                c = read();
            }
            return buf.toString();
        }

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public boolean hasNext() {
            int value;
            while (isSpaceChar(value = peek()) && value != -1)
                read();
            return value != -1;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}


import java.io.*;
import java.util.*;
public class Main
{
	HashMap<Integer,Pair> map;
	int n,a[];
	private void solve()throws IOException
	{
		n=nextInt();
		a=new int[n+1];
		for(int i=1;i<=n;i++)
			a[i]=nextInt();
		map=new HashMap<>();
		for(int i=1;i<=n;i++)
		{
			int sum=0;
			for(int j=i;j>=1;j--)
			{
				sum+=a[j];
				if(!map.containsKey(sum))
					map.put(sum,new Pair(i,1));
				else
				{
					Pair p=map.get(sum);
					if(p.pos<j)
						map.put(sum,new Pair(i,p.cnt+1));
				}
			}
		}
		int sum=0,ans=0;
		for(int i:map.keySet())
			if(map.get(i).cnt>ans)
			{
				ans=map.get(i).cnt;
				sum=i;
			}
		out.println(ans);
		ArrayList<String> list=new ArrayList<>();
		for(int i=1,prev=0;i<=n;i++)
		{
			int s=0;
			for(int j=i;j>=1;j--)
			{
				s+=a[j];
				if(s==sum && j>prev)
				{
					list.add(j+" "+i);
					prev=i;
				}
			}
		}
		for(String s:list)
			out.println(s);
	}
	class Pair{
	    int pos,cnt;
	    Pair(int a,int b){
	        pos=a;
	        cnt=b;
	    }
	}

	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();

		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}


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

public class B implements Runnable {
	FastReader scn;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int n = scn.nextInt();
		int[] arr = scn.nextIntArray(n);

		int[][] a = new int[n * (n + 1) / 2][];
		int[] need = new int[a.length];
		int pos = 0;
		for (int l = 0; l < n; l++) {
			int sum = 0;
			for (int r = l; r < n; r++) {
				sum += arr[r];
				a[pos] = new int[] { l, r, sum };
				need[pos++] = sum;
			}
		}

		need = scn.uniq(need);

		int[][][] list = new int[need.length][][];
		int[] size = new int[list.length];

		for (int i = 0; i < pos; i++) {
			size[Arrays.binarySearch(need, a[i][2])]++;
		}
		for (int i = 0; i < list.length; i++) {
			list[i] = new int[size[i]][];
		}
		for (int i = 0; i < pos; i++) {
			int ind = Arrays.binarySearch(need, a[i][2]);
			list[ind][--size[ind]] = new int[] { a[i][0], a[i][1] };
		}

		int ind = -1, max = 0;

		for (int i = 0; i < list.length; i++) {
			if(list[i].length == 0) {
				continue;
			}
			Arrays.sort(list[i], (o1, o2) -> o1[1] - o2[1]);

			int count = 1, last = list[i][0][1];
			for(int j = 1; j < list[i].length; j++) {
				if(list[i][j][0] > last) {
					count++;
					last = list[i][j][1];
				}
			}

			if (count > max) {
				max = count;
				ind = i;
			}
		}

		out.println(max);
		int last = list[ind][0][1];
		out.println((list[ind][0][0] + 1) + " " + (list[ind][0][1] + 1));

		for(int i = 1; i < list[ind].length; i++) {
			if(list[ind][i][0] > last) {
				out.println((list[ind][i][0] + 1) + " " + (list[ind][i][1] + 1));
				last = list[ind][i][1];
			}
		}
	}

	public void run() {
		long time = System.currentTimeMillis();
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		out = new PrintWriter(System.out);
		scn = new FastReader(oj);
		solve();
		out.flush();
		if (!oj) {
			System.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + " ms" }));
		}
	}

	public static void main(String[] args) {
		new Thread(null, new B(), "Main", 1 << 26).start();
	}

	class FastReader {
		InputStream is;

		public FastReader(boolean onlineJudge) {
			is = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

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

		char nextChar() {
			return (char) skip();
		}

		String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		String nextLine() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while ((!isSpaceChar(b) || b == ' ')) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

		int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		int[][] next2DInt(int n, int m) {
			int[][] arr = new int[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextIntArray(m);
			}
			return arr;
		}

		long[][] next2DLong(int n, int m) {
			long[][] arr = new long[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLongArray(m);
			}
			return arr;
		}

		int[] shuffle(int[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				arr[i] = arr[i] ^ arr[j];
				arr[j] = arr[i] ^ arr[j];
				arr[i] = arr[i] ^ arr[j];
			}
			return arr;
		}

		int[] uniq(int[] arr) {
			Arrays.sort(arr);
			int[] rv = new int[arr.length];
			int pos = 0;
			rv[pos++] = arr[0];
			for (int i = 1; i < arr.length; i++) {
				if (arr[i] != arr[i - 1]) {
					rv[pos++] = arr[i];
				}
			}
			return Arrays.copyOf(rv, pos);
		}

		int[] reverse(int[] arr) {
			int l = 0, r = arr.length - 1;
			while (l < r) {
				arr[l] = arr[l] ^ arr[r];
				arr[r] = arr[l] ^ arr[r];
				arr[l] = arr[l] ^ arr[r];
				l++;
				r--;
			}
			return arr;
		}

	}
}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class SolutionArch2 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.valueOf(scanner.nextLine());
        String s = scanner.nextLine();
        int[] arr = Arrays.stream(s.split(" "))
                .mapToInt(Integer::valueOf)
                .toArray();
        int[] prefixSum = new int[n + 1];
        for (int i = 0; i < n; i++) {
            prefixSum[i + 1] = prefixSum[i] + arr[i];
        }
        Map<Integer, List<int[]>> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                int subarraySum = prefixSum[j + 1] - prefixSum[i];
                map.putIfAbsent(subarraySum, new ArrayList<>());
                int l = i + 1, r = j + 1;
                map.get(subarraySum).add(new int[]{l, r});
            }
        }
        List<int[]> resultPairs = new ArrayList<>();
        for (Map.Entry<Integer, List<int[]>> e : map.entrySet()) {
            List<int[]> result = new ArrayList<>();
            int[] curr = new int[2];
            List<int[]> pairs = e.getValue();
            Collections.sort(pairs, Comparator.<int[]>comparingInt(a -> a[1]));
            for (int[] next : pairs) {
                if (next[0] > curr[1]) {
                    result.add(next);
                    curr = next;
                }
            }
            if (resultPairs.size() < result.size()) {
                resultPairs = result;
            }
        }
        printResult(resultPairs);
    }

    private static void printResult(List<int[]> list) {
        StringBuilder sb = new StringBuilder();
        sb.append(list.size()).append("\n");
        for (int[] pair : list) {
            sb.append(pair[0]).append(" ").append(pair[1]).append("\n");
        }
        System.out.print(sb);
    }
}


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

public final class Solution {
    BufferedReader br;
    StringTokenizer st;

    {
        st = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public static void main(String[] args) throws Exception {
        new Solution().run();
    }

    void run() throws Exception {
        int n = ni();
        int[] a = new int[n];
        for(int i=0; i<n; i++) a[i] = ni();
        for(int i=1; i<n; i++) a[i] += a[i-1];

        HashMap<Integer, List<Point>> map = new HashMap<>();
        for(int i=0; i<n; i++) {
            for(int j=i; j<n; j++) {
                int sum = getSum(a, i, j);
                if(!map.containsKey(sum)) map.put(sum, new ArrayList<>());
                map.get(sum).add(new Point(i+1, j+1));
            }
        }

        for(int key : map.keySet()) {
            Collections.sort(map.get(key), new Comparator<Point>() {
                @Override
                public int compare(Point p1, Point p2) {
                    if(p1.x == p2.x) return p1.y - p2.y;
                    return p1.x - p2.x;
                }
            });
        }

        Stack<Point> stack = new Stack<>();
        for(int key : map.keySet()) {
            Stack<Point> st = getPairs(map.get(key));
            if(st.size() > stack.size()) stack = st;
        }

        pl(stack.size());
        while(!stack.isEmpty()) {
            Point p = stack.pop();
            pl(p.x + " " + p.y);
        }
    }

    Stack<Point> getPairs(List<Point> list) {
        Stack<Point> stack = new Stack<>();
        stack.push(list.get(0));
        for(int i=1; i<list.size(); i++) {
            Point p = list.get(i);
            if(p.x >= stack.peek().x && p.x <= stack.peek().y) {
                Point p2 = stack.pop();
                if(p2.y < p.y) {
                    stack.push(p2);
                } else {
                    stack.push(p );
                }
            } else {
                stack.push(p);
            }
        }
        return stack;
    }

    int getSum(int[] a, int l, int r) {
        return (l == 0) ? a[r] : a[r] - a[l-1];
    }

    class Node {
        HashSet<Integer> adj;
        public Node() {
            adj = new HashSet<>();
        }
    }

    // I/O
    String nt() throws Exception {
        if(st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine(), " ");
        }
        return st.nextToken();
    }

    int ni() throws Exception {
        return Integer.parseInt(nt());
    }

    long nl() throws Exception {
        return Long.parseLong(nt());
    }

    void p(Object o) {
        System.out.print(o);
    }

    void pl(Object o) {
        System.out.println(o);
    }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.*;

public class P1141F {

	static BufferedReader br;
	static BufferedWriter bw;
	static StringTokenizer st;

	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		bw = new BufferedWriter(new OutputStreamWriter(System.out));

		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		int[][] b = new int[n][n];
		HashMap<Integer, ArrayList<Integer>> map = new HashMap<Integer, ArrayList<Integer>>();

		st = new StringTokenizer(br.readLine());
		for(int i = 0; i < n; ++i) {
			a[i] = Integer.parseInt(st.nextToken());

			int r = i;
			b[r][r] = a[r];
			if (!map.containsKey(b[r][r]))
				map.put(b[r][r], new ArrayList<Integer>());
			for(int l = 0; l < r; ++l) {
				b[l][r] = b[l][r-1] + a[r];
				if (!map.containsKey(b[l][r]))
					map.put(b[l][r], new ArrayList<Integer>());
			}
		}

		for(int r = 0; r < n; ++r) {
			for(int l = 0; l <= r; ++l) {
				int sum = b[l][r];
				ArrayList<Integer> intervals = map.get(sum);
				int last_r = -1;
				if(!intervals.isEmpty())
					last_r = intervals.get(intervals.size()-1);

				if(l > last_r) {
					intervals.add(l);
					intervals.add(r);
				}

			}
		}

		//int best_sum = -1;
		ArrayList<Integer> best_intervals = new ArrayList<Integer>();

		for(Map.Entry<Integer, ArrayList<Integer>> entry : map.entrySet()) {
			//int sum = entry.getKey();
			ArrayList<Integer> intervals = entry.getValue();

			if(intervals.size() > best_intervals.size()) {
				best_intervals = intervals;
			}
		}

		bw.write(best_intervals.size()/2 + "\n");
		for(int i = 0; i < best_intervals.size(); i += 2) {
			bw.write((best_intervals.get(i)+1) + " " + (best_intervals.get(i+1)+1) + "\n");
		}

		br.close();
		bw.close();
	}
}


//package sept;

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

public class TimePass implements Runnable {
    InputStream is;
    PrintWriter out;
    String INPUT = "";
    //boolean debug=false;
    boolean debug=true;
    static long mod=998244353;
    static long mod2=1000000007;

    void solve() throws IOException
    {
        int n=ni();
        int[] a=na(n);
        long[] sum=new long[n];
        sum[0]=a[0];
        for(int i=1;i<n;i++)sum[i]=sum[i-1]+a[i];
        HashMap<Long,ArrayList<Pair>> map=new HashMap<>();
        for(int i=0;i<n;i++)
        {
            for(int j=i;j<n;j++)
            {
                long curr=sum[j]-(i>0?sum[i-1]:0);
                if(map.containsKey(curr))
                {
                    map.get(curr).add(new Pair(i+1,j+1));
                }
                else
                {
                    ArrayList<Pair> list=new ArrayList<>();
                    list.add(new Pair(i+1,j+1));
                    map.put(curr,list);
                }
            }
        }
        int max=0;
        long maxSum=0;
        for(long key:map.keySet())
        {
            ArrayList<Pair> list=map.get(key);
            list.sort(new Comparator<Pair>(){
                public int compare(Pair p1,Pair p2)
                {
                    return p1.b-p2.b;
                }
            });
            int prevl=0;
            int cnt=0;
            for(Pair pr:list)
            {
                if(pr.a>prevl)
                {
                    cnt++;
                    prevl=pr.b;
                }
            }
            if(max<cnt)
            {
                max=cnt;
                maxSum=key;
            }
        }
        int prevl=0;
        ArrayList<Pair> list=map.get(maxSum);
        ArrayList<Pair> ans=new ArrayList<>();
        for(Pair pr:list)
        {
            if(pr.a>prevl)
            {
                //cnt++;
                ans.add(pr);
                //out.println(pr.a+" "+pr.b);
                prevl=pr.b;
            }
        }
        out.println(ans.size());
        for(Pair pr:ans)
        {
            out.println(pr.a+" "+pr.b);
        }
    }

    static long fnc(int a,int b)
    {
        return a+(long)1000000007*b;
    }

    static Pair[][] packU(int n,int[] from,Pair[] to)
    {
        Pair[][] g=new Pair[n][];
        int[] p=new int[n];
        for(int f:from)
        {
            p[f]++;
        }
        int m=from.length;
        for(int i=0;i<n;i++)
        {
            g[i]=new Pair[p[i]];
        }
        for(int i=0;i<m;i++)
        {
            g[from[i]][--p[from[i]]]=to[i];
        }
        return g;
    }

    static int[][] packD(int n,int[] from,int[] to)
    {
        int[][] g=new int[n][];
        int[] p=new int[n];
        for(int f:from)
        {
            p[f]++;
        }
        int m=from.length;
        for(int i=0;i<n;i++)
        {
            g[i]=new int[p[i]];
        }
        for(int i=0;i<m;i++)
        {
            g[from[i]][--p[from[i]]]=to[i];
        }
        return g;
    }

    static class Pair
    {
        int a,b,c;
        public Pair(int a,int b
        //,int c
        )
        {
            this.a=a;
            this.b=b;
            //this.c=c;
        }
    }

    static long lcm(int a,int b)
    {
        long val=a;
        val*=b;
        return (val/gcd(a,b));
    }

    static long gcd(long a,long b)
    {
        if(a==0)return b;
        return gcd(b%a,a);
    }

    static int pow(int a, int b, int p)
    {
        long ans = 1, base = a;
        while (b!=0)
        {
            if ((b & 1)!=0)
            {
                ans *= base;
                ans%= p;
            }
            base *= base;
            base%= p;
            b >>= 1;
        }
        return (int)ans;
    }

    static int inv(int x, int p)
    {
        return pow(x, p - 2, p);
    }

    public static long[] radixSort(long[] f){ return radixSort(f, f.length); }
    public static long[] radixSort(long[] f, int n)
    {
        long[] to = new long[n];
        {
            int[] b = new int[65537];
            for(int i = 0;i < n;i++)b[1+(int)(f[i]&0xffff)]++;
            for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
            for(int i = 0;i < n;i++)to[b[(int)(f[i]&0xffff)]++] = f[i];
            long[] d = f; f = to;to = d;
        }
        {
            int[] b = new int[65537];
            for(int i = 0;i < n;i++)b[1+(int)(f[i]>>>16&0xffff)]++;
            for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
            for(int i = 0;i < n;i++)to[b[(int)(f[i]>>>16&0xffff)]++] = f[i];
            long[] d = f; f = to;to = d;
        }
        {
            int[] b = new int[65537];
            for(int i = 0;i < n;i++)b[1+(int)(f[i]>>>32&0xffff)]++;
            for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
            for(int i = 0;i < n;i++)to[b[(int)(f[i]>>>32&0xffff)]++] = f[i];
            long[] d = f; f = to;to = d;
        }
        {
            int[] b = new int[65537];
            for(int i = 0;i < n;i++)b[1+(int)(f[i]>>>48&0xffff)]++;
            for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
            for(int i = 0;i < n;i++)to[b[(int)(f[i]>>>48&0xffff)]++] = f[i];
            long[] d = f; f = to;to = d;
        }
        return f;
    }

    public void run()
    {
        if(debug)oj=true;
        is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        out = new PrintWriter(System.out);

        long s = System.currentTimeMillis();
        try {
            solve();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        out.flush();
        tr(System.currentTimeMillis()-s+"ms");
    }

    public static void main(String[] args) throws Exception {new Thread(null,new TimePass(),"Main",1<<26).start();}

    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;

    private int readByte()
    {
        if(lenbuf == -1)throw new InputMismatchException();
        if(ptrbuf >= lenbuf){
            ptrbuf = 0;
            try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
            if(lenbuf <= 0)return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
    private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

    private double nd() { return Double.parseDouble(ns()); }
    private char nc() { return (char)skip(); }

    private String ns()
    {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n)
    {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while(p < n && !(isSpaceChar(b))){
            buf[p++] = (char)b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m)
    {
        char[][] map = new char[n][];
        for(int i = 0;i < n;i++)map[i] = ns(m);
        return map;
    }

    private int[] na(int n)
    {
        int[] a = new int[n];
        for(int i = 0;i < n;i++)a[i] = ni();
        return a;
    }

    private int ni()
    {
        int num = 0, b;
        boolean minus = false;
        while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if(b == '-'){
            minus = true;
            b = readByte();
        }

        while(true){
            if(b >= '0' && b <= '9'){
                num = num * 10 + (b - '0');
            }else{
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl()
    {
        long num = 0;
        int b;
        boolean minus = false;
        while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if(b == '-'){
            minus = true;
            b = readByte();
        }

        while(true){
            if(b >= '0' && b <= '9'){
                num = num * 10 + (b - '0');
            }else{
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
    private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] arr = new int[n];

        arr[0] = sc.nextInt();

        for (int i = 1; i < n; i++) {
            arr[i] = arr[i - 1] + sc.nextInt();
        }

        HashMap<Integer, List<Pair>> map = new HashMap<>();

        for (int i = 0; i < n; i++) {

            if (map.containsKey(arr[i])) map.get(arr[i]).add(new Pair(0, i));
            else {
                List<Pair> l = new ArrayList<>();
                l.add(new Pair(0, i));
                map.put(arr[i], l);
            }

            for (int j = 1; j <= i; j++) {
                int ss = arr[i] - arr[j - 1];
                if (map.containsKey(ss)) map.get(ss).add(new Pair(j, i));
                else {
                    List<Pair> l = new ArrayList<>();
                    l.add(new Pair(j, i));
                    map.put(ss, l);
                }
            }
        }

        List<Pair> el = null;

        for (List<Pair> value : map.values()) {
            value.sort(Comparator.comparingInt(Pair::getStart));
            ArrayList<Pair> ps = new ArrayList<>();
            Pair last = value.get(0);

            for (int i = 1; i < value.size(); i++) {
                if (last.getEnd() < value.get(i).getStart()) {
                    ps.add(last);
                    last = value.get(i);
                }
                else if (last.getEnd() > value.get(i).getEnd()) last = value.get(i);
            }

            ps.add(last);

            if (el == null) el = ps;
            else if (ps.size() > el.size()) el = ps;
        }

        System.out.println(el.size());

        for (Pair pair : el) {
            System.out.println((pair.getStart() + 1) + " " + (pair.getEnd() + 1));
        }

    }
}

class Pair {
    private final int start;
    private final int end;

    public int getStart() {
        return start;
    }

    public int getEnd() {
        return end;
    }

    public Pair(int start, int end) {
        this.start = start;
        this.end = end;
    }
}


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

public class Main{
class Node implements Comparable<Node>{
    int l;
    int r;
    public Node(int l,int r){
        this.l=l;
        this.r=r;
    }
    public int compareTo(Node c){
        int t=Integer.compare(this.r,c.r);
        if(t!=0) return t;
        t=Integer.compare(this.l,c.l);
        return t;
    }
}
    void solve() {
        int n=ni();
        int a[]=new int[n+1];
        long pref[]=new long[n+1];
        for(int i=1;i<=n;i++){
            a[i]=ni();
            pref[i]=pref[i-1]+a[i];
        }
        PriorityQueue<Long> q=new PriorityQueue<>();
        for(int i=1;i<=n;i++){
            for(int j=i;j<=n;j++) q.offer(pref[j]-pref[i-1]);
        }
        int sz=1;
        while(!q.isEmpty()){
            long val=q.poll();
            if(!mp.containsKey(val)){
               mp.put(val,sz++);
            }
        }
        vec=new Node[sz][];
        int size[]=new int[sz];
        for(int i=1;i<=n;i++){
            for(int j=i;j<=n;j++) size[mp.get(pref[j]-pref[i-1])]++;
        }
        for(int i=1;i<sz;i++) vec[i]=new Node[size[i]];
        for(int i=1;i<=n;i++){
            for(int j=i;j<=n;j++) {
                int idx=mp.get(pref[j]-pref[i-1]);
                vec[idx][--size[idx]]=new Node(i,j);
            }
        }

        for(int i=1;i<sz;i++) Arrays.sort(vec[i]);
        for(int i=1;i<sz;i++){
            solve(vec[i]);
        }
        pw.println(ans.size());
        for(Node p : ans) pw.println(p.l+" "+p.r);

    }
    HashMap<Long,Integer> mp=new HashMap<>();
    Node vec[][];
    int cnt=0;
    ArrayList<Node> ans=new ArrayList<>();
    void solve(Node [] v){
        int n=v.length;
        if(n==0) return;
        int dp[]=new int[n+1];
        int prev[]=new int[n+1];
        int mx[]=new int[n+1];
        int mxid[]=new int[n+1];
        for(int i=1;i<=n;i++){
            Node p=v[i-1];
            dp[i]=dp[i-1];
            prev[i]=-1;
            int l=1,r=i-1;
            int idx=0;
            while(l<=r){
                int mid=(l+r)>>1;
                if(v[mid-1].r<p.l){
                    idx=mid;
                    l=mid+1;
                }else r=mid-1;
            }
            if(1+mx[idx]>dp[i]){
                dp[i]=1+mx[idx];
                prev[i]=mxid[idx];
            }
            mx[i]=mx[i-1];
            mxid[i]=mxid[i-1];
            if(dp[i]>mx[i]){
                mx[i]=dp[i];
                mxid[i]=i;
            }

        }
        if (dp[n] > cnt){
            cnt=dp[n];
            ans.clear();
            int id=n;
            while(id>0){
                if(dp[id]==dp[id-1]){
                    id--;
                    continue;
                }
                ans.add(new Node(v[id-1].l,v[id-1].r));
                id=prev[id];
            }
        }
    }
    long M = (long)1e9+7;
    InputStream is;
    PrintWriter pw;
    String INPUT = "";

    void run() throws Exception {
        is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        pw = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
        solve();
        pw.flush();
        if (!INPUT.isEmpty()) tr(System.currentTimeMillis() - s + "ms");

    }

    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m) {
        char[][] map = new char[n][];
        for (int i = 0; i < n; i++) map[i] = ns(m);
        return map;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

    private void tr(Object... o) {
        if (INPUT.length() > 0) System.out.println(Arrays.deepToString(o));
    }

}