import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.LinkedList;
import java.util.Comparator;
import java.util.Collections;
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);
        OutputWriter out = new OutputWriter(outputStream);
        Task547F solver = new Task547F();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task547F {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            long arr[] = in.nextLongArray(n);
            long cur = 0;
            int i, j;
            Map<Long, List<Pair>> hm = new HashMap<>();

            for (i = 0; i < n; i++) {
                cur = 0;
                for (j = i; j < n; j++) {
                    cur += arr[j];
                    if (!hm.containsKey(cur)) {
                        List<Pair> al = new LinkedList<>();
                        al.add(new Pair(i + 1, j + 1));
                        hm.put(cur, al);
                    } else {
                        List<Pair> al = hm.get(cur);
                        al.add(new Pair(i + 1, j + 1));
                        hm.put(cur, al);
                    }
                }
            }
            //out.println(hm);
            long max = arr[0];
            int msize = 0;
            for (long key : hm.keySet()) {
                List<Pair> al = hm.get(key);
                if (al.size() < hm.get(max).size())
                    continue;
                Collections.sort(al, new Comparator<Pair>() {

                    public int compare(Pair o1, Pair o2) {
                        if (o1.b != o2.b)
                            return o1.b - o2.b;
                        return o1.a - o2.a;
                    }
                });
                //out.println(al);
                List<Pair> all = new LinkedList<>();
                int prev = -1;
                for (Pair p : al) {
                    if (p.a > prev) {
                        all.add(p);
                        prev = p.b;
                    }
                }
                //out.println(all);

                hm.put(key, all);
                //out.println(all.size());
                if (all.size() > msize) {
                    //out.println("ca" + msize + " " + all.size());
                    msize = all.size();
                    max = key;
                }

            }
            //out.println(hm);

            List<Pair> al = hm.get(max);
            out.println(al.size());
            for (Pair p : al) {
                out.println(p.a + " " + p.b);
            }

        }

        class Pair {
            int a;
            int b;

            public Pair(int a, int b) {
                this.a = a;
                this.b = b;
            }

            public String toString() {
                return "(" + a + ", " + b + ")";
            }

        }

    }

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

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

        public 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 (isSpaceChar(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 (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                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 res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

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

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

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void println(int i) {
            writer.println(i);
        }

    }
}


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

public class Soln {

	public static int[] io(int n) {
    	int[] d = new int[n];
    	for (int i=0;i<n;i++) d[i] = f.nextInt();
    	return d;
	}
	public static int binlog( int bits ){
        int log = 0;
        if( ( bits & 0xffff0000 ) != 0 ) { bits >>>= 16; log = 16; }
        if( bits >= 256 ) { bits >>>= 8; log += 8; }
        if( bits >= 16  ) { bits >>>= 4; log += 4; }
        if( bits >= 4   ) { bits >>>= 2; log += 2; }
        return log + ( bits >>> 1 );
    }
	static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
	}
	public static final long mod = (long)Math.pow(10, 9) + 7;
	static FastReader f=new FastReader();

	public static void main (String[] args) throws IOException{
		int n = f.nextInt();
		int[] a = io(n);
		HashMap<Integer,ArrayList<ivl>> hm = new HashMap<>();
		for (int i=0;i<n;i++) {
			int sum = 0;
			for (int j=i;j<n;j++) {
				sum+=a[j];
				if (hm.get(sum)==null) hm.put(sum,new ArrayList<ivl>());
				hm.get(sum).add(new ivl(i,j));
			}
		}
		HashSet<ivl> hs = new HashSet<ivl>();

		for (ArrayList<ivl> arr : hm.values()) {
			Collections.sort(arr,new comp());
			HashSet<ivl> temp = new HashSet<ivl>();
			temp.add(arr.get(0));
			int lastr = arr.get(0).r;
			int num = 1;
			for (ivl curr:arr) {
				if (curr.l>lastr) {
					lastr = curr.r;
					num++;
					temp.add(curr);
				}
			}
			if (temp.size()>hs.size()) hs = temp;
		}

		System.out.println(hs.size());
		for (ivl curr:hs) {
			System.out.println((curr.l+1)+" "+(curr.r+1));
		}
    }

	static class ivl{
		int l,r;
		ivl(int l,int r){
			this.l=l;this.r=r;
		}
	}

	static class comp implements Comparator<ivl>{
		public int compare(ivl a,ivl b) {
			if (a.r - b.r == 0) return a.l-b.l;
			return a.r-b.r;
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

public class F{

	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
	static class Pair
	{
		int l;
		int r;
		Pair(int l,int r)
		{
			this.l = l;
			this.r = r;
		}
	}
	public static void main(String[] args)
	{
		OutputStream outputStream = System.out;
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(outputStream);
        int n = sc.nextInt();
        int a[] = new int[n];
        Pair pr;
        HashMap<Long,ArrayList> hm = new HashMap<>();
        ArrayList<Pair> ar;
        for(int i = 0; i < n; i++)
        {
        	a[i] = sc.nextInt();
        }
        long sum = 0;
        for(int r = 0; r < n; r++)
        {
        	sum = 0;
        	for(int l = r; l >= 0; l--)
        	{
        		sum += a[l];
        		if(!hm.containsKey(sum))
        		{
        			ar = new ArrayList<>();
        			ar.add(new Pair(l,r));
        			hm.put(sum,ar);
        		}
        		else
        		{
        			ar = hm.get(sum);
        			ar.add(new Pair(l,r));
        			hm.put(sum,ar);
        		}
        	}
        }

        int count = 0;
        int maxCount = 0;
        long maxSum = 0;
        for(Map.Entry<Long,ArrayList> entry:hm.entrySet())
        {
        	sum = entry.getKey();
        	ar = entry.getValue();
        	count = 0;
        	int r = -1;
        	for(int i = 0; i < ar.size(); i++)
        	{
        		if(ar.get(i).l > r)
        		{
        			count++;
        			r = ar.get(i).r;
        		}
        	}
        	if(count > maxCount)
        	{
        		maxCount = count;
        		maxSum = sum;
        	}

        }
        ar = hm.get(maxSum);
        out.println(maxCount);
        //out.println((ar.get(0).l+1)+" "+(ar.get(0).r+1));

        int r = -1;
        for(int i = 0; i < ar.size(); i++)
    	{
    		if(ar.get(i).l > r)
    		{
    			out.println((ar.get(i).l+1) +" "+(ar.get(i).r+1));
    			r = ar.get(i).r;
    		}
    	}
        out.close();
	}

}


import java.io.PrintWriter;

import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        PrintWriter out=new PrintWriter(System.out);

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

        HashMap<Integer,ArrayList<Node>> h=new HashMap<>();
        for (int i = 0; i <n ; i++) {
            int sum=0;
            for (int j = i; j <n ; j++) {
                sum+=a[j];
                if(h.containsKey(sum)){
                    h.get(sum).add(new Node(i,j));
                }
                else{
                    ArrayList<Node> temp=new ArrayList<>();
                    temp.add(new Node(i,j));
                    h.put(sum,temp);
                }
            }
        }

        long ans=0;
        ArrayList<Integer> ansList=new ArrayList<>();

        for(int x:h.keySet()){
            Collections.sort(h.get(x), new Comparator<Node>() {
                @Override
                public int compare(Node o1, Node o2) {
                    return Integer.compare(o1.r,o2.r);
                }
            });

            ArrayList<Node>  l=h.get(x);
            //out.println(l);
            ArrayList<Integer> temp=new ArrayList<>();
            int lasty=Integer.MIN_VALUE;
            for (int i = 0; i <l.size() ; i++) {
                if(l.get(i).l>lasty){
                    lasty=l.get(i).r;
                    temp.add(l.get(i).l);
                    temp.add(l.get(i).r);
                }
            }

            if(ans<temp.size()){
                ansList=temp;
                ans=ansList.size();
            }
        }

        out.println(ans/2);
        for (int i = 0; i <ansList.size() ; i++) {
            out.print((ansList.get(i)+1)+" ");
            i++;
            out.println((ansList.get(i)+1)+" ");
        }

        out.close();
    }

    static class Node{
        int l,r;
        public Node(int a,int b){
            l=a;
            r=b;
        }
    }

}


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

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class cf1141f2_2 {

    public static void main(String[] args) throws IOException {
        int n = ri(), a[] = ria(n), pre[] = new int[n + 1];
        for (int i = 0; i < n; ++i) {
            pre[i + 1] = pre[i] + a[i];
        }
        Map<Integer, List<p>> sums = new HashMap<>();
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j <= i; ++j) {
                sums.computeIfAbsent(pre[i + 1] - pre[j], k -> new ArrayList<>()).add(new p(j, i));
            }
        }
        int k = 0;
        List<p> ans = new ArrayList<>();
        for (int key : sums.keySet()) {
            List<p> segs = sums.get(key);
            segs.sort((x, y) -> x.b == y.b ? x.a - y.a : x.b - y.b);
            int last = -1, cnt = 0;
            for (int i = 0, end = segs.size(); i < end; ++i) {
                if (segs.get(i).a > last) {
                    ++cnt;
                    last = segs.get(i).b;
                }
            }
            if (cnt > k) {
                k = cnt;
                ans = segs;
            }
        }
        prln(k);
        int last = -1;
        for (int i = 0, end = ans.size(); i < end; ++i) {
            if (ans.get(i).a > last) {
                prln(ans.get(i).a + 1, ans.get(i).b + 1);
                last = ans.get(i).b;
            }
        }
        close();
    }

    static class p {
        int a, b;

        p(int a_, int b_) {
            a = a_;
            b = b_;
        }

        @Override
        public String toString() {
            return "Pair{" + "a = " + a + ", b = " + b + '}';
        }

        public boolean asymmetricEquals(Object o) {
            p p = (p) o;
            return a == p.a && b == p.b;
        }

        public boolean symmetricEquals(Object o) {
            p p = (p) o;
            return a == p.a && b == p.b || a == p.b && b == p.a;
        }

        @Override
        public boolean equals(Object o) {
            return asymmetricEquals(o);
        }

        public int asymmetricHashCode() {
            return Objects.hash(a, b);
        }

        public int symmetricHashCode() {
            return Objects.hash(a, b) + Objects.hash(b, a);
        }

        @Override
        public int hashCode() {
            return asymmetricHashCode();
        }
    }

    static BufferedReader __in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer input;
    static Random __rand = new Random();

    // references
    // IBIG = 1e9 + 7
    // IMAX ~= 2e9
    // LMAX ~= 9e18

    // constants
    static final int IBIG = 1000000007;
    static final int IMAX = 2147483647;
    static final int IMIN = -2147483648;
    static final long LMAX = 9223372036854775807L;
    static final long LMIN = -9223372036854775808L;
    // math util
    static int minof(int a, int b, int c) {return min(a, min(b, c));}
    static int minof(int... x) {if (x.length == 1) return x[0]; if (x.length == 2) return min(x[0], x[1]); if (x.length == 3) return min(x[0], min(x[1], x[2])); int min = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i]; return min;}
    static long minof(long a, long b, long c) {return min(a, min(b, c));}
    static long minof(long... x) {if (x.length == 1) return x[0]; if (x.length == 2) return min(x[0], x[1]); if (x.length == 3) return min(x[0], min(x[1], x[2])); long min = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i]; return min;}
    static int maxof(int a, int b, int c) {return max(a, max(b, c));}
    static int maxof(int... x) {if (x.length == 1) return x[0]; if (x.length == 2) return max(x[0], x[1]); if (x.length == 3) return max(x[0], max(x[1], x[2])); int max = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i]; return max;}
    static long maxof(long a, long b, long c) {return max(a, max(b, c));}
    static long maxof(long... x) {if (x.length == 1) return x[0]; if (x.length == 2) return max(x[0], x[1]); if (x.length == 3) return max(x[0], max(x[1], x[2])); long max = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i]; return max;}
    static int powi(int a, int b) {if (a == 0) return 0; int ans = 1; while (b > 0) {if ((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static long powl(long a, int b) {if (a == 0) return 0; long ans = 1; while (b > 0) {if ((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static int fli(double d) {return (int) d;}
    static int cei(double d) {return (int) ceil(d);}
    static long fll(double d) {return (long) d;}
    static long cel(double d) {return (long) ceil(d);}
    static int gcf(int a, int b) {return b == 0 ? a : gcf(b, a % b);}
    static long gcf(long a, long b) {return b == 0 ? a : gcf(b, a % b);}
    static int lcm(int a, int b) {return a * b / gcf(a, b);}
    static long lcm(long a, long b) {return a * b / gcf(a, b);}
    static int randInt(int min, int max) {return __rand.nextInt(max - min + 1) + min;}
    static long mix(long x) {x += 0x9e3779b97f4a7c15L; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9L; x = (x ^ (x >> 27)) * 0x94d049bb133111ebL; return x ^ (x >> 31);}
    // array util
    static void reverse(int[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {int swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(long[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {long swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(double[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {double swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(char[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {char swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void shuffle(int[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); int swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(long[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); long swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(double[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); double swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void rsort(int[] a) {shuffle(a); sort(a);}
    static void rsort(long[] a) {shuffle(a); sort(a);}
    static void rsort(double[] a) {shuffle(a); sort(a);}
    static int[] copy(int[] a) {int[] ans = new int[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static long[] copy(long[] a) {long[] ans = new long[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static double[] copy(double[] a) {double[] ans = new double[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static char[] copy(char[] a) {char[] ans = new char[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    // graph util
    static List<List<Integer>> g(int n) {List<List<Integer>> g = new ArrayList<>(); for (int i = 0; i < n; ++i) g.add(new ArrayList<>()); return g;}
    static List<Set<Integer>> sg(int n) {List<Set<Integer>> g = new ArrayList<>(); for (int i = 0; i < n; ++i) g.add(new HashSet<>()); return g;}
    static void c(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).add(v); g.get(v).add(u);}
    static void cto(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).add(v);}
    static void dc(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).remove(v); g.get(v).remove(u);}
    static void dcto(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).remove(v);}
    // input
    static void r() throws IOException {input = new StringTokenizer(rline());}
    static int ri() throws IOException {return Integer.parseInt(rline());}
    static long rl() throws IOException {return Long.parseLong(rline());}
    static double rd() throws IOException {return Double.parseDouble(rline());}
    static int[] ria(int n) throws IOException {int[] a = new int[n]; r(); for (int i = 0; i < n; ++i) a[i] = ni(); return a;}
    static int[] riam1(int n) throws IOException {int[] a = new int[n]; r(); for (int i = 0; i < n; ++i) a[i] = ni() - 1; return a;}
    static long[] rla(int n) throws IOException {long[] a = new long[n]; r(); for (int i = 0; i < n; ++i) a[i] = nl(); return a;}
    static double[] rda(int n) throws IOException {double[] a = new double[n]; r(); for (int i = 0; i < n; ++i) a[i] = nd(); return a;}
    static char[] rcha() throws IOException {return rline().toCharArray();}
    static String rline() throws IOException {return __in.readLine();}
    static String n() {return input.nextToken();}
    static int rni() throws IOException {r(); return ni();}
    static int ni() {return Integer.parseInt(n());}
    static long rnl() throws IOException {r(); return nl();}
    static long nl() {return Long.parseLong(n());}
    static double rnd() throws IOException {r(); return nd();}
    static double nd() {return Double.parseDouble(n());}
    static List<List<Integer>> rg(int n, int m) throws IOException {List<List<Integer>> g = g(n); for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1); return g;}
    static void rg(List<List<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1);}
    static List<List<Integer>> rdg(int n, int m) throws IOException {List<List<Integer>> g = g(n); for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1); return g;}
    static void rdg(List<List<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1);}
    static List<Set<Integer>> rsg(int n, int m) throws IOException {List<Set<Integer>> g = sg(n); for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1); return g;}
    static void rsg(List<Set<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1);}
    static List<Set<Integer>> rdsg(int n, int m) throws IOException {List<Set<Integer>> g = sg(n); for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1); return g;}
    static void rdsg(List<Set<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1);}
    // output
    static void pr(int i) {__out.print(i);}
    static void prln(int i) {__out.println(i);}
    static void pr(long l) {__out.print(l);}
    static void prln(long l) {__out.println(l);}
    static void pr(double d) {__out.print(d);}
    static void prln(double d) {__out.println(d);}
    static void pr(char c) {__out.print(c);}
    static void prln(char c) {__out.println(c);}
    static void pr(char[] s) {__out.print(new String(s));}
    static void prln(char[] s) {__out.println(new String(s));}
    static void pr(String s) {__out.print(s);}
    static void prln(String s) {__out.println(s);}
    static void pr(Object o) {__out.print(o);}
    static void prln(Object o) {__out.println(o);}
    static void prln() {__out.println();}
    static void pryes() {prln("yes");}
    static void pry() {prln("Yes");}
    static void prY() {prln("YES");}
    static void prno() {prln("no");}
    static void prn() {prln("No");}
    static void prN() {prln("NO");}
    static void pryesno(boolean b) {prln(b ? "yes" : "no");};
    static void pryn(boolean b) {prln(b ? "Yes" : "No");}
    static void prYN(boolean b) {prln(b ? "YES" : "NO");}
    static void prln(int... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static void prln(long... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static void prln(double... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static <T> void prln(Collection<T> c) {int n = c.size() - 1; Iterator<T> iter = c.iterator(); for (int i = 0; i < n; pr(iter.next()), pr(' '), ++i); if (n >= 0) prln(iter.next()); else prln();}
    static void h() {prln("hlfd"); flush();}
    static void flush() {__out.flush();}
    static void close() {__out.close();}}


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<Long, ArrayList<Interval>> 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) == false) {
                        map.put(sum, new ArrayList<>());
                    }
                    ArrayList<Interval> arr = map.get(sum);
                    if (arr.isEmpty() || arr.get(arr.size() - 1).r < i) {
                        arr.add(new Interval(i, j));
                    } else if (arr.get(arr.size() - 1).r >= j) {
                        arr.set(arr.size() - 1, new Interval(i, j));
                    }
                }
            }

            ArrayList<Interval> best = new ArrayList<>();
            for (ArrayList<Interval> arr : map.values()) {
                if (best.size() < arr.size()) {
                    best = arr;
                }
            }

            out.println(best.size());
            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.util.*;

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[]){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int x[] = new int[a];
		for(int n=0;n<a;n++){
			x[n] = in.nextInt();
		}
		int max = 1;
		int t = 0;
		HashMap<Integer, ArrayList<node>> map = new HashMap<Integer, ArrayList<node>>();
		for(int n=0;n<a;n++){
			int num = 0;
			for(int m=n;m<a;m++){
				num += x[m];
				node node = new node(n, m);
				if(!map.containsKey(num)){
					ArrayList<node> list = new ArrayList<node>();
					list.add(node);
					map.put(num, list);
					if(max == 1)t = num;
				}
				else{
					ArrayList<node> list = map.get(num);
					int left = 0;
					int right = list.size()-1;
					int res = list.size();
					while(left <= right){
						int mid = (left + right) >> 1;
						//System.out.println(mid +" "+ left +" " +right);
						if(list.get(mid).r >= n){
							res = mid;
							right = mid - 1;
						}
						else{
							left = mid + 1;
						}
					}
					if(res == list.size()){
						list.add(node);
						if(max < res+1){
							max = res+1;
							t = num;
						}
					}
					else if(list.get(res).r>m){
						list.set(res, node);
						if(max < res){
							max = list.size();
							t = num;
						}
					}

				}
			}
		}
		System.out.println(max);
		for(int n=0;n<max;n++){
			System.out.println((map.get(t).get(n).l+1)+" "+(map.get(t).get(n).r+1));
		}

	}
}


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

public class Q3 {

    static class Pair {
        int a;
        int b;

        Pair(int p, int q) {
            a = p;
            b = q;
        }
    }

    public static void main(String[] args) {

        InputReader in = new InputReader();
        int N = in.nextInt();
        int arr[] = new int[N];

        for (int i = 0; i < N; i++)
            arr[i] = in.nextInt();

        HashMap<Integer, ArrayList<Pair>> name = new HashMap<>();

        for (int i = 0; i < N; i++) {
            int sum = 0;
            for (int j = i; j < N; j++) {
                sum += arr[j];
                if (name.get(sum) == null)
                    name.put(sum, new ArrayList());

                name.get(sum).add(new Pair(i+1, j+1));
            }
        }

        HashSet<Pair> ans = new HashSet<>();

        for (ArrayList<Pair> n : name.values()) {
            Collections.sort(n, new Comparator<Pair>() {
                @Override
                public int compare(Pair o1, Pair o2) {
                    if (Integer.compare(o1.b, o2.b) == 0)
                        return Integer.compare(o1.a, o2.a);
                    return Integer.compare(o1.b, o2.b);
                }
            });

            HashSet<Pair> temp = new HashSet<>();
            temp.add(n.get(0));
            int num = 1;
            int r = n.get(0).b;

            for (int i = 1; i < n.size(); i++) {

                if (n.get(i).a > r) {
                    num++;
                    r = n.get(i).b;
                    temp.add(n.get(i));
                }
            }

            if (num > ans.size())
                ans = temp;
        }

        System.out.println(ans.size());
        for (Pair val : ans)
            System.out.println(val.a + " " + val.b);

    }

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

        public 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;
        }

        public InputReader() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(System.in), 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 char nextChar() {
            return next().charAt(0);
        }

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

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

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

        public int[] nextIntArr(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = this.nextInt();
            }
            return arr;
        }

        public Integer[] nextIntegerArr(int n) {
            Integer[] arr = new Integer[n];
            for (int i = 0; i < n; i++)
                arr[i] = new Integer(this.nextInt());

            return arr;
        }

        public int[][] next2DIntArr(int n, int m) {
            int[][] arr = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    arr[i][j] = this.nextInt();
                }
            }
            return arr;
        }

        public int[] nextSortedIntArr(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = this.nextInt();
            }
            Arrays.sort(arr);
            return arr;
        }

        public long[] nextLongArr(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = this.nextLong();
            }
            return arr;
        }

        public char[] nextCharArr(int n) {
            char[] arr = new char[n];
            for (int i = 0; i < n; i++) {
                arr[i] = this.nextChar();
            }
            return arr;
        }

        public static int gcd(int a, int b) {
            return b == 0 ? a : gcd(b, a % b);
        }

        public static int[] uwiSieve(int n) {
            if (n <= 32) {
                int[] primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31};
                for (int i = 0; i < primes.length; i++) {
                    if (n < primes[i]) {
                        return Arrays.copyOf(primes, i);
                    }
                }
                return primes;
            }

            int u = n + 32;
            double lu = Math.log(u);
            int[] ret = new int[(int) (u / lu + u / lu / lu * 1.5)];
            ret[0] = 2;
            int pos = 1;

            int[] isp = new int[(n + 1) / 32 / 2 + 1];
            int sup = (n + 1) / 32 / 2 + 1;

            int[] tprimes = {3, 5, 7, 11, 13, 17, 19, 23, 29, 31};
            for (int tp : tprimes) {
                ret[pos++] = tp;
                int[] ptn = new int[tp];
                for (int i = (tp - 3) / 2; i < tp << 5; i += tp)
                    ptn[i >> 5] |= 1 << (i & 31);
                for (int i = 0; i < tp; i++) {
                    for (int j = i; j < sup; j += tp)
                        isp[j] |= ptn[i];
                }
            }

            // 3,5,7
            // 2x+3=n
            int[] magic = {0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13, 31, 22, 28, 18, 26, 10, 7, 12, 21, 17,
                    9, 6, 16, 5, 15, 14};
            int h = n / 2;
            for (int i = 0; i < sup; i++) {
                for (int j = ~isp[i]; j != 0; j &= j - 1) {
                    int pp = i << 5 | magic[(j & -j) * 0x076be629 >>> 27];
                    int p = 2 * pp + 3;
                    if (p > n)
                        break;
                    ret[pos++] = p;
                    for (int q = pp; q <= h; q += p)
                        isp[q >> 5] |= 1 << (q & 31);
                }
            }

            return Arrays.copyOf(ret, pos);
        }

        public static int[] radixSort(int[] f) {
            return radixSort(f, f.length);
        }

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

}

// for(Map.Entry<Integer,Integer> Test: map.entrySet()){
//            int Key=Test.getKey();
//            int val=Test.getValue();
//        }


/*
Keep solving problems.
*/

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

public class CFA {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    private static final long MOD = 1000L * 1000L * 1000L + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};
    private static final String yes = "Yes";
    private static final String no = "No";

    int n;
    int[] arr;
    class Segment {
        int start;
        int end;
        public Segment(int start, int end) {
            this.start = start;
            this.end = end;
        }

        @Override
        public String toString() {
            return start + " " + end;
        }
    }
    Map<Integer, List<Segment>> hm = new HashMap<>();
    void solve() throws IOException {
        n = nextInt();
        arr = nextIntArr(n);
        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = i; j < n; j++) {
                sum += arr[j];
                if (!hm.containsKey(sum)) {
                    hm.put(sum, new ArrayList<>());
                }

                hm.get(sum).add(new Segment(i, j));
            }
        }

        int max = -1;
        int idx = -1;
        for (Map.Entry<Integer, List<Segment>> entry : hm.entrySet()) {
            int key = entry.getKey();
            List<Segment> values = entry.getValue();
            Collections.sort(values, new Comparator<Segment>() {
                @Override
                public int compare(Segment o1, Segment o2) {
                    return Integer.compare(o1.end, o2.end);
                }
            });
            int cnt = findSeg(values).size();
            if (cnt > max) {
                max = cnt;
                idx = key;
            }
        }

        List<Segment> res = findSeg(hm.get(idx));
        outln(res.size());
        for (int i = 0; i < res.size(); i++) {
            outln((1 + res.get(i).start) + " " + (1 + res.get(i).end));
        }
    }

    List<Segment> findSeg(List<Segment> input) {
        List<Segment> res = new ArrayList<>();
        int bound = -1;
        for (int i = 0; i < input.size(); i++) {
            if (input.get(i).start > bound) {
                res.add(input.get(i));
                bound = input.get(i).end;
            }
        }

        return res;
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    long gcd(long a, long b) {
        while(a != 0 && b != 0) {
            long c = b;
            b = a % b;
            a = c;
        }
        return a + b;
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    private void formatPrint(double val) {
        outln(String.format("%.9f%n", val));
    }
    public CFA() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new CFA();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}


// package CF1141;

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

public class CF1141F1 {
    static FastReader s;
    static PrintWriter out;
    static String INPUT = "7\n" +
            "4 1 2 2 1 5 3\n";

    public static void main(String[] args) {
        long time = System.currentTimeMillis();
        boolean oj = System.getProperty("ONLINE_JUDGE") != null;
        out = new PrintWriter(System.out);
        s = new FastReader(oj);
        int n = s.nextInt();
        int[] arr = s.nextIntArray(n);
        int[] sum = new int[n];
        sum[0] = arr[0];
        for (int i = 1; i < n; i++) {
            sum[i] = sum[i - 1] + arr[i];
        }

//        int max = Integer.MIN_VALUE;
        HashMap<Integer, ArrayList<pair>> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                if(i == 0) {
                    ArrayList<pair> list = map.getOrDefault(sum[j], new ArrayList<>());
                    list.add(new pair(i, j));
                    map.put(sum[j], list);
                } else {
                    ArrayList<pair> list = map.getOrDefault(sum[j] - sum[i - 1], new ArrayList<>());
                    list.add(new pair(i, j));
                    map.put(sum[j] - sum[i - 1], list);
                }
            }
        }

        ArrayList<Integer> keys = new ArrayList<>(map.keySet());
        ArrayList<pair> ans = null;
        for (int curr : keys) {
            ArrayList<pair> list = map.get(curr);
            Collections.sort(list);
            ArrayList<pair> smallAns = new ArrayList<>();
            smallAns.add(list.get(0));
            for (int k = 1; k < list.size(); k++) {
                if(list.get(k).start > smallAns.get(smallAns.size() - 1).finish) {
                    smallAns.add(list.get(k));
                }
            }

            if(ans == null) {
                ans = smallAns;
            } else {
                if(ans.size() < smallAns.size()) {
                    ans = smallAns;
                }
            }
        }

//        out.println(ans.size() + "\n" + ans);
//
//        out.println(map);
//
//        out.println(Arrays.toString(sum));
        StringBuilder ans1 = new StringBuilder();
        ans1.append(ans.size() + "\n");
        for (pair p : ans) {
            ans1.append((p.start + 1) + " " + (p.finish + 1));
            ans1.append("\n");
        }
        out.println(ans1);

        if (!oj) {
            System.out.println(Arrays.deepToString(new Object[]{System.currentTimeMillis() - time + " ms"}));
        }
        out.flush();
    }

    private static class pair implements Comparable<pair>{
        int start;
        int finish;

        public pair(int start, int finish) {
            this.start = start;
            this.finish = finish;
        }

        @Override
        public int compareTo(pair o) {
            return Integer.compare(this.finish, o.finish);
        }

        @Override
        public String toString() {
            return this.start + " " + this.finish;
        }
    }
    private static class Matrix {

        static long[][] I;
        static long mod = 1000000007;

        public static long[][] exp(long[][] M, long n) {
            if (n <= 0) {
                I = new long[M.length][M.length];
                for (int i = 0; i < M.length; i++) {
                    I[i][i] = 1L;
                }
                return I;
            }
            if (n == 1) return M;
            long[][] res = exp(M, n / 2);
            res = mult(res, res);
            if (n % 2 == 0) return res;
            return mult(res, M);
        }

        public static long[][] mult(long[][] p, long[][] q) {
            long[][] r = new long[p.length][q[0].length];
            for (int i = 0; i < p.length; i++)
                for (int j = 0; j < q[0].length; j++)
                    for (int k = 0; k < q.length; k++) {
                        r[i][j] += p[i][k] * q[k][j];
                        r[i][j] %= mod;
                    }
            return r;
        }
    }

    private static class Maths {
        static ArrayList<Long> printDivisors(long n) {
            // Note that this loop runs till square root
            ArrayList<Long> list = new ArrayList<>();
            for (long i = 1; i <= Math.sqrt(n); i++) {
                if (n % i == 0) {
                    if (n / i == i) {
                        list.add(i);
                    } else {
                        list.add(i);
                        list.add(n / i);
                    }
                }
            }
            return list;
        }

        //    GCD - Using Euclid theorem.
        private static long gcd(long a, long b) {
            if (b == 0) {
                return a;
            }

            return gcd(b, a % b);
        }

        //    Extended euclidean algorithm
//    Used to solve equations of the form ax + by = gcd(a,b)
//    return array [d, a, b] such that d = gcd(p, q), ap + bq = d
        static long[] extendedEuclidean(long p, long q) {
            if (q == 0)
                return new long[]{p, 1, 0};

            long[] vals = extendedEuclidean(q, p % q);
            long d = vals[0];
            long a = vals[2];
            long b = vals[1] - (p / q) * vals[2];
            return new long[]{d, a, b};
        }

        // X ^ y mod p
        static long power(long x, long y, long p) {
            long res = 1;
            x = x % p;

            while (y > 0) {
                if ((y & 1) == 1)
                    res = (res * x) % p;
                y = y >> 1;
                x = (x * x) % p;
            }
            return res;
        }

        // Returns modulo inverse of a
        // with respect to m using extended
        // Euclid Algorithm. Refer below post for details:
        // https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/
        static long inv(long a, long m) {
            long m0 = m, t, q;
            long x0 = 0, x1 = 1;

            if (m == 1)
                return 0;

            // Apply extended Euclid Algorithm
            while (a > 1) {
                q = a / m;
                t = m;
                m = a % m;
                a = t;
                t = x0;
                x0 = x1 - q * x0;
                x1 = t;
            }

            // Make x1 positive
            if (x1 < 0)
                x1 += m0;

            return x1;
        }

        // k is size of num[] and rem[].
        // Returns the smallest number
        // x such that:
        // x % num[0] = rem[0],
        // x % num[1] = rem[1],
        // ..................
        // x % num[k-2] = rem[k-1]
        // Assumption: Numbers in num[] are pairwise
        // coprime (gcd for every pair is 1)
        static long findMinX(long num[], long rem[], long k) {
            int prod = 1;
            for (int i = 0; i < k; i++)
                prod *= num[i];

            int result = 0;
            for (int i = 0; i < k; i++) {
                long pp = prod / num[i];
                result += rem[i] * inv(pp, num[i]) * pp;
            }

            return result % prod;
        }
    }

    private static class BS {
        //  Binary search
        private static int binarySearch(int[] arr, int ele) {
            int low = 0;
            int high = arr.length - 1;
            while (low <= high) {
                int mid = (low + high) / 2;
                if (arr[mid] == ele) {
                    return mid;
                } else if (ele < arr[mid]) {
                    high = mid - 1;
                } else {
                    low = mid + 1;
                }
            }
            return -1;
        }

        //    First occurence using binary search
        private static int binarySearchFirstOccurence(int[] arr, int ele) {
            int low = 0;
            int high = arr.length - 1;
            int ans = -1;
            while (low <= high) {
                int mid = (low + high) / 2;
                if (arr[mid] == ele) {
                    ans = mid;
                    high = mid - 1;
                } else if (ele < arr[mid]) {
                    high = mid - 1;
                } else {
                    low = mid + 1;
                }
            }
            return ans;
        }

        //    Last occurenece using binary search
        private static int binarySearchLastOccurence(int[] arr, int ele) {
            int low = 0;
            int high = arr.length - 1;
            int ans = -1;
            while (low <= high) {
                int mid = (low + high) / 2;
                if (arr[mid] == ele) {
                    ans = mid;
                    low = mid + 1;
                } else if (ele < arr[mid]) {
                    high = mid - 1;
                } else {
                    low = mid + 1;
                }
            }
            return ans;
        }
    }

    private static class arrays {
        // Merge sort
        static void merge(int arr[], int l, int m, int r) {
            int n1 = m - l + 1;
            int n2 = r - m;
            int L[] = new int[n1];
            int R[] = new int[n2];
            for (int i = 0; i < n1; ++i)
                L[i] = arr[l + i];
            for (int j = 0; j < n2; ++j)
                R[j] = arr[m + 1 + j];
            int i = 0, j = 0;
            int k = l;
            while (i < n1 && j < n2) {
                if (L[i] <= R[j]) {
                    arr[k] = L[i];
                    i++;
                } else {
                    arr[k] = R[j];
                    j++;
                }
                k++;
            }

            while (i < n1) {
                arr[k] = L[i];
                i++;
                k++;
            }

            while (j < n2) {
                arr[k] = R[j];
                j++;
                k++;
            }
        }

        static void sort(int arr[], int l, int r) {
            if (l < r) {
                int m = (l + r) / 2;
                sort(arr, l, m);
                sort(arr, m + 1, r);
                merge(arr, l, m, r);
            }
        }

        static void sort(int[] arr) {
            sort(arr, 0, arr.length - 1);
        }
    }

    private static class UnionFindDisjointSet {
        int[] parent;
        int[] size;
        int n;
        int size1;

        public UnionFindDisjointSet(int n) {
            this.n = n;
            this.parent = new int[n];
            this.size = new int[n];
            for (int i = 0; i < n; i++) {
                parent[i] = i;
            }

            for (int i = 0; i < n; i++) {
                size[i] = 1;
            }

            this.size1 = n;
        }

        private int numDisjointSets() {
            System.out.println(size1);
            return size1;
        }

        private boolean find(int a, int b) {
            int rootA = root(a);
            int rootB = root(b);
            if (rootA == rootB) {
                return true;
            }
            return false;
        }

        private int root(int b) {
            if (parent[b] != b) {
                return parent[b] = root(parent[b]);
            }
            return b;
        }

        private void union(int a, int b) {
            int rootA = root(a);
            int rootB = root(b);
            if (rootA == rootB) {
                return;
            }

            if (size[rootA] < size[rootB]) {
                parent[rootA] = parent[rootB];
                size[rootB] += size[rootA];
            } else {
                parent[rootB] = parent[rootA];
                size[rootA] += size[rootB];
            }
            size1--;
            System.out.println(Arrays.toString(parent));
        }
    }

    private static class SegTree {
        int[] st;
        int[] arr;

        public SegTree(int[] arr) {
            this.arr = arr;
            int size = (int) Math.ceil(Math.log(arr.length) / Math.log(2));
            st = new int[(int) ((2 * Math.pow(2, size)) - 1)];
            buildSegmentTree(1, 0, arr.length - 1);
        }

        //**********JUST CALL THE CONSTRUCTOR, THIS FUNCTION WILL BE CALLED AUTOMATICALLY******
        private void buildSegmentTree(int index, int L, int R) {
            if (L == R) {
                st[index] = arr[L];
                return;
            }

            buildSegmentTree(index * 2, L, (L + R) / 2);
            buildSegmentTree(index * 2 + 1, (L + R) / 2 + 1, R);
//          Replace this line if you want to change the function of the Segment tree.
            st[index] = Math.min(st[index * 2], st[index * 2 + 1]);
        }

        //***********We have to use this function **************
        private int Query(int queL, int queR) {
            return Query1(1, 0, arr.length - 1, queL, queR);
        }

        //This is a helper function.
        //************* DO NOT USE THIS ****************
        private int Query1(int index, int segL, int segR, int queL, int queR) {
            if (queL > segR || queR < segL) {
                return -1;
            }

            if (queL <= segL && queR >= segR) {
                return st[index];
            }

            int ans1 = Query1(index * 2, segL, (segL + segR) / 2, queL, queR);
            int ans2 = Query1(index * 2 + 1, (segL + segR) / 2 + 1, segR, queL, queR);
            if (ans1 == -1) {
                return ans2;
            }

            if (ans2 == -1) {
                return ans1;
            }
//             Segment tree implemented for range minimum query. Change the below line to change the function.
            return Math.min(ans1, ans2);
        }

        private void update(int idx, int val) {
            update1(1, 0, arr.length - 1, idx, val);
        }

        private void update1(int node, int queL, int queR, int idx, int val) {
            // idx - index to be updated in the array
            // node - index to be updated in the seg tree
            if (queL == queR) {
                // Leaf node
                arr[idx] += val;
                st[node] += val;
            } else {
                int mid = (queL + queR) / 2;
                if (queL <= idx && idx <= mid) {
                    // If idx is in the left child, recurse on the left child
                    update1(2 * node, queL, mid, idx, val);
                } else {
                    // if idx is in the right child, recurse on the right child
                    update1(2 * node + 1, mid + 1, queR, idx, val);
                }
                // Internal node will have the min of both of its children
                st[node] = Math.min(st[2 * node], st[2 * node + 1]);
            }
        }
    }

    private static 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);
        }
    }

}


//package codeforces_464_div2;

import java.util.*;
import java.util.stream.Collectors;

public class F {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) arr[i] = sc.nextInt();
        int[][] sub = new int[n][n];
        for (int i = 0; i < n; i++) {
            sub[i][i] = arr[i];
            for (int j = i + 1; j < n; j++) {
                sub[i][j] = sub[i][j - 1] + arr[j];
            }
        }

        HashMap<Integer, List<P>> hm = new HashMap<>();
        /*for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                if (hm.containsKey(sub[i][j])) {
                    hm.get(sub[i][j]).add(new P(i, j));
                } else {
                    List<P> temp = new ArrayList<>();
                    temp.add(new P(i, j));
                    hm.put(sub[i][j], temp);
                }
            }
        }*/
        for(int stop=0; stop<n; stop++) {
            for(int start=0; start<=stop; start++) {
                if (hm.containsKey(sub[start][stop])) {
                    hm.get(sub[start][stop]).add(new P(start, stop));
                } else {
                    List<P> temp = new ArrayList<>();
                    temp.add(new P(start, stop));
                    hm.put(sub[start][stop], temp);
                }
            }
        }

        int ans = Integer.MIN_VALUE;
        /*for(Map.Entry it : hm.entrySet()) {
            int or = overlap(it.getValue());
            ans = Math.max(ans, or);
        }*/

        List<P> ansList = null;
        for (List<P> it : hm.values()) {
            int or = overlap(it);
            if(or>ans) {
                ans = or;
                ansList = it;
            }
        }

        List<P> processedList = extractOverlapping(ansList);

        System.out.println(ans);
        for(int i=0; i<processedList.size(); i++) {
            int A = processedList.get(i).a + 1;
            int B = processedList.get(i).b + 1;
            System.out.println(A + " " + B);
        }
    }

    public static int overlap(List<P> listOfPair) {
        /*List<P> sortedList = listOfPair.stream()
                .sorted((pair1, pair2) -> pair1.getB().compareTo(pair2.getB()))
                .collect(Collectors.toList());*/
        List<P> sortedList = listOfPair;

        int cnt = 0;
        int end = sortedList.get(0).b;
        for (int i = 1; i < sortedList.size(); i++) {
            if (sortedList.get(i).a <= end) {
                cnt++;
            } else {
                end = sortedList.get(i).b;
            }
        }

        return sortedList.size() - cnt;
    }

    public static List<P> extractOverlapping(List<P> ansList) {
        List<P> sortedList = ansList.stream()
                .sorted((pair1, pair2) -> pair1.getB().compareTo(pair2.getB()))
                .collect(Collectors.toList());

        List<P> finalList = new ArrayList<>();
        finalList.add(sortedList.get(0));
        int end = sortedList.get(0).b;
        for (int i = 1; i < sortedList.size(); i++) {
            if (sortedList.get(i).a <= end) {
                continue;
            } else {
                finalList.add(sortedList.get(i));
                end = sortedList.get(i).b;
            }
        }

        return finalList;
    }
}

class P implements Comparable<P> {
    Integer a;
    Integer b;

    public P(int a, int b) {
        this.a = a;
        this.b = b;
    }

    public Integer getA() {
        return a;
    }

    public Integer getB() {
        return b;
    }

    @Override
    public int compareTo(P that) {
        return this.b.compareTo(that.b);
    }
}


import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[])
    {
        FastReader input=new FastReader();
        PrintWriter out=new PrintWriter(System.out);
        int T=1;
        while(T-->0)
        {
            int n=input.nextInt();
            int a[]=new int[n];
            for(int i=0;i<n;i++)
            {
                a[i]=input.nextInt();
            }
            HashMap<Integer,ArrayList<Pair>> map=new HashMap<>();
            for(int i=0;i<n;i++)
            {
                int sum=0;
                for(int j=i;j<n;j++)
                {
                    sum+=a[j];
                    if(map.containsKey(sum))
                    {
                        map.get(sum).add(new Pair(i,j));
                    }
                    else
                    {
                        map.put(sum,new ArrayList<>());
                        map.get(sum).add(new Pair(i,j));
                    }
                }
            }
            int max=Integer.MIN_VALUE;
            Iterator it=map.entrySet().iterator();
            ArrayList<Pair> setBlocks=new ArrayList<>();
            while(it.hasNext())
            {
                Map.Entry e=(Map.Entry)it.next();
                ArrayList<Pair> list=(ArrayList)e.getValue();
                Collections.sort(list, new Comparator<Pair>() {
                    @Override
                    public int compare(Pair o1, Pair o2) {
                        if(o1.l==o2.l)
                        {
                            return o1.r-o2.r;
                        }
                        else
                        {
                            return o1.l-o2.l;
                        }
                    }
                });
                Pair1 sufMin[]=new Pair1[list.size()];
                TreeSet<Pair> set=new TreeSet<>(new Comparator<Pair>() {
                    @Override
                    public int compare(Pair o1, Pair o2) {
                        if(o1.l==o2.l)
                        {
                            return o1.r-o2.r;
                        }
                        else
                        {
                            return o1.l-o2.l;
                        }
                    }
                });
                int min=Integer.MAX_VALUE;
                int index=-1;
                for(int j=list.size()-1;j>=0;j--)
                {
                    if(min>=list.get(j).r)
                    {
                        min=list.get(j).r;
                        index=j;
                    }
                    sufMin[j]=new Pair1(min,index);
                    set.add(new Pair(list.get(j).l,j));
                }
                int count=0;
                int j=0;
                ArrayList<Pair> blocks=new ArrayList<>();
                while(j<list.size())
                {
                    int m=sufMin[j].min;
                    int ind=sufMin[j].index;
                    blocks.add(list.get(ind));
                    count++;
                    Pair p=new Pair(m+1,0);
                    if(set.ceiling(p)==null)
                    {
                        break;
                    }
                    else
                    {
                        Pair p1=set.ceiling(p);
                        j=p1.r;
                    }
                }
                if(max<count)
                {
                    max=count;
                    setBlocks=blocks;
                }
            }
            out.println(max);
            for(int i=0;i<setBlocks.size();i++)
            {
                out.println((setBlocks.get(i).l+1)+" "+(setBlocks.get(i).r+1));
            }
        }
        out.close();
    }
    public static class Pair1
    {
        int min,index;
        Pair1(int min,int index)
        {
            this.min=min;
            this.index=index;
        }
    }
    public static class Pair
    {
        int l,r;
        Pair(int l,int r)
        {
            this.l=l;
            this.r=r;
        }
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt()
        {
            return Integer.parseInt(next());
        }
        long nextLong()
        {
            return Long.parseLong(next());
        }
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
        String nextLine()
        {
            String str="";
            try
            {
                str=br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


//package codeforces;

import java.util.ArrayList;
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 SameSumBlocksHard {

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

		int n = in .nextInt();

		long[] a = new long[n + 1];
		long[] sum = new long[n + 1];

		for (int i = 1; i <= n; i++) {
			a[i] = in.nextInt();
			sum[i] = sum[i - 1] + a[i];
		}

		Map<Long, List<int[]>> map = new HashMap<>();

		for (int i = 1; i <= n; i++) {
			for (int j = i; j <= n; j++) {
				long x = sum[j] - sum[i - 1];
				List<int[]> list = map.get(x);
				if (list == null) {
					list = new ArrayList<>();
					map.put(x, list);
				}
				list.add(new int[] {i, j});
			}
		}

		List<int[]> ans = new ArrayList<>();
		for (Map.Entry<Long, List<int[]>> entry : map.entrySet()) {
			List<int[]> list = entry.getValue();
			List<int[]> tmp = new ArrayList<>();
			calc(list, tmp);
			if (tmp.size() > ans.size()) {
				ans.clear();
				ans.addAll(tmp);
			}
		}

		System.out.println(ans.size());
		for (int[] pair : ans) {
			System.out.println(pair[0] + " " + pair[1]);
		}

		in.close();
	}

	static void calc(List<int[]> list, List<int[]> tmp) {
		Collections.sort(list, new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				if (o1[1] < o2[1]) {
					return -1;
				} else if (o1[1] > o2[1]) {
					return 1;
				} else {
					return 0;
				}
			}
		});

		int last = -1;
		for (int[] p : list) {
			if (last == -1) {
				last = p[1];
				tmp.add(p);
			} else if (p[0] > last) {
				last = p[1];
				tmp.add(p);
			}
		}
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
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.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Liavontsi Brechka
 */
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);
        F1BlokiRavnoiSummiProstayaRedakciya solver = new F1BlokiRavnoiSummiProstayaRedakciya();
        solver.solve(1, in, out);
        out.close();
    }

    static class F1BlokiRavnoiSummiProstayaRedakciya
    {
        InputReader in;
        Map<Long, List<F1BlokiRavnoiSummiProstayaRedakciya.Block>> sums;

        public void solve(int testNumber, InputReader in, PrintWriter out)
        {
            this.in = in;

            int n = ni();
            long[] a = nla(n);

            sums = new HashMap<>();
            for (int i = 0; i < n; i++)
            {
                long sum = 0;
                for (int j = i; j < n; j++)
                {
                    sum += a[j];
                    sums.computeIfAbsent(sum, k -> new ArrayList<>()).add(
                                    new F1BlokiRavnoiSummiProstayaRedakciya.Block(i, j, sum));
                }
            }

            for (Map.Entry<Long, List<F1BlokiRavnoiSummiProstayaRedakciya.Block>> e : sums.entrySet())
            {
                Collections.sort(e.getValue());
            }

            List<F1BlokiRavnoiSummiProstayaRedakciya.Block> res = Collections.emptyList();
            for (Map.Entry<Long, List<F1BlokiRavnoiSummiProstayaRedakciya.Block>> e : sums.entrySet())
            {
                List<F1BlokiRavnoiSummiProstayaRedakciya.Block> blocks = e.getValue();
                List<F1BlokiRavnoiSummiProstayaRedakciya.Block> updated = new ArrayList<>();

                if (blocks.size() <= res.size())
                    continue;

                for (F1BlokiRavnoiSummiProstayaRedakciya.Block next : blocks)
                {
                    if (updated.size() == 0)
                        updated.add(next);
                    else
                    {
                        F1BlokiRavnoiSummiProstayaRedakciya.Block prev = updated.get(updated.size() - 1);
                        if (next.l > prev.r)
                            updated.add(next);
                    }
                }

                if (updated.size() > res.size())
                    res = updated;
            }

            StringBuilder resS = new StringBuilder();
            resS.append(res.size()).append('\n');
            for (F1BlokiRavnoiSummiProstayaRedakciya.Block block : res)
                resS.append(block.l + 1).append(' ').append(block.r + 1).append('\n');

            out.println(resS);
        }

        private long[] nla(int size)
        {
            return in.nextLongArray(size);
        }

        private int ni()
        {
            return in.nextInt();
        }

        static class Block implements Comparable<F1BlokiRavnoiSummiProstayaRedakciya.Block>
        {
            int l;
            int r;
            long sum;

            public Block(int l, int r, long sum)
            {
                this.l = l;
                this.r = r;
                this.sum = sum;
            }

            public int compareTo(F1BlokiRavnoiSummiProstayaRedakciya.Block o)
            {
                int res = Integer.compare(r, o.r);
                if (res == 0)
                    res = Integer.compare(l, o.l);
                return res;
            }

        }

    }

    static class InputReader
    {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream in)
        {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public long[] nextLongArray(int size)
        {
            long[] array = new long[size];
            for (int i = 0; i < size; ++i)
            {
                array[i] = nextLong();
            }
            return array;
        }

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

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

        public String next()
        {
            while (tokenizer == null || !tokenizer.hasMoreTokens())
            {
                tokenizer = new StringTokenizer(readLine());
            }
            return tokenizer.nextToken();
        }

        public String readLine()
        {
            String line;
            try
            {
                line = reader.readLine();
            }
            catch (IOException e)
            {
                throw new RuntimeException(e);
            }
            return line;
        }

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Comparator;
import java.util.HashMap;
import java.util.TreeMap;

public class Main extends PrintWriter {

    static BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
    // static Scanner s=new Scanner(System.in);
    Main () { super(System.out); }
    public static void main(String[] args) throws IOException{
        Main  d1=new Main   ();d1.main();d1.flush();
    }
    void main() throws IOException {
        BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
        StringBuffer sb = new StringBuffer();
        StringBuffer sb1 = new StringBuffer();
        PrintWriter out = new PrintWriter(System.out);
        int t=1;
//        t=i(s()[0]);
        while(t-->0) {
            //dp[i]=a[i]+max(dp[j]) S.T. j<i and h[j]<h[i];
            String[] s1 = s();
            int n = i(s1[0]);
             long[] a=new long[n];
             arr(a,n);
             HashMap<Long,Integer>[] dp=new HashMap[n];

             long[] presum=new long[n];
             for(int i=0;i<n;i++){
                 if(i==0){
                     presum[i]=a[i];
                 }else{
                     presum[i]=a[i]+presum[i-1];
                 }
             }HashMap<Long,TreeMap<Integer,Long> > tm=new HashMap<>();int ans=0;long maxsum=0;
             for(int i=0;i<n;i++){
                  dp[i]=new HashMap<>();
                 for(int j=-1;j<i;j++){
                     long sum=0;
                     if(j==-1) sum=presum[i];else sum=presum[i]-presum[j];
//                     if(sum==5&&i==5) System.out.println(tm.get(sum).floorKey(4));
                     if(tm.containsKey(sum)&&tm.get(sum).floorKey(j)!=null){
                         dp[i].put(sum,Math.max(dp[i].getOrDefault(sum,0),dp[tm.get(sum).floorKey(j)].getOrDefault(sum,0)+1));
                        if(dp[i].get(sum)>ans){
                            maxsum=sum;
                        }
                         ans=Math.max(ans,dp[i].get(sum));
                     }else if(dp[i].containsKey(sum)==false){
                         if(dp[i].getOrDefault(sum,0)<1) dp[i].put(sum,1);
                         if(dp[i].get(sum)>ans){
                             maxsum=sum;
                         }
                         ans=Math.max(ans,1);
                     }
                     long val=dp[i].getOrDefault(sum,0);
//                     if(tm.containsKey(sum)&&tm.get(sum).floorKey(i-1)!=null){
                         if(!tm.containsKey(sum)||tm.get(sum).floorKey(i-1)==null||dp[tm.get(sum).floorKey(i-1)].getOrDefault(sum,0)<val) {
//                             val = Math.max(val, dp[tm.get(sum).floorKey(i - 1)].getOrDefault(sum, 0));
                             TreeMap<Integer, Long> tt = new TreeMap<>();
                             tt.put(i, val);
                             tm.put(sum, tt);
                         }
//                     }
                     }
             }int cnt=0;int last=-1;
             for(int i=0;i<n;i++){
                 for(int j=i-1;j>=-1;j--){
                     long sum=0;
                     if(j==-1) sum=presum[i];
                     else sum=presum[i]-presum[j];
                     if(dp[i].getOrDefault(maxsum,0)>cnt&&maxsum==sum){
                         sb.append(j+2+" "+(i+1)+"\n");cnt++;
                         break;
                     }
                 }
             } System.out.println(ans);
//            System.out.println(dp[5].get(5L)+" "+dp[4].get(5L));
            System.out.println(sb);
        }

    }
    //        System.out.println(sb);
    long[] st;
    void buildtree(int i,int s,int e,long[] a){
        if(s==e){
            st[i]=a[s];
            return;
        }
        int mid=(s+e)/2;
        buildtree(2*i,s,mid,a);
        buildtree(2*i+1,mid+1,e,a);
        st[i]=Math.min(st[2*i],st[2*(i)+1]);
    }
    long query(int i,int s,int e,int qs,int qe){
        if(qs>e||qe<s) return Integer.MIN_VALUE;
        if(s>=qs&&e<=qe) return st[i];
        int mid=(s+e)/2;
        long l=query(2*i,s,mid,qs,qe);
        long r=query(2*i+1,mid+1,e,qs,qe);
        return Math.max(l,r);
    }
    void pointupdate(int i,int s,int e,int qi,long [] a){
        if(s==e){
            st[i]=a[s];return;
        }
        int mid=(s+e)/2;
        if(qi<=mid) pointupdate(2*i,s,mid,qi,a);
        else pointupdate(2*(i)+1,mid+1,e,qi,a);
        st[i]=Math.max(st[2*i],st[2*i+1]);
    }
    public void arr(long[] a,int n) throws IOException{
        //        BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
        String[] s2=s();
        for(int i=0;i<n;i++){
            a[i]=i(s2[i]);
        }
    }
    public void sort(int[] a,int l,int h){
        if(l==h) return;
        int mid=(l+h)/2;

        sort(a,l,mid);
        sort(a,mid+1,h);
        merge(a,l,(l+h)/2,h);
    }
    void merge(int arr[], int l, int m, int r)
    {
        int n1 = m - l + 1;
        int n2 = r - m;
        int L[] = new int[n1];
        int R[] = new int[n2];
        for (int i = 0; i < n1; ++i)
            L[i] = arr[l + i];
        for (int j = 0; j < n2; ++j)
            R[j] = arr[m + 1 + j];
        int i = 0, j = 0;
        int k = l;
        while (i < n1 && j < n2) {
            if (L[i] <= R[j]) {
                arr[k] = L[i];
                i++;
            }
            else {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        while (i < n1) {
            arr[k] = L[i];
            i++;
            k++;
        }
        while (j < n2) {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    static long gcd(long a, long b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }
    static String[] s() throws IOException {
        return s.readLine().trim().split("\\s+");
    }

    static int i(String ss) {
        return Integer.parseInt(ss);
    }
    static long l(String ss) {
        return Long.parseLong(ss);
    }
}
class Student {
    long  a;int b;int c;
    public Student(int a,int b) {
        this.a=a;this.c=c;this.b=b;
    }
}
class Pair {
    int  a,b,c;
    public Pair(int  a,int b){
        this.a=a;this.b=b;this.c=c;}
}
class Sortbyroll implements Comparator<Student> {

    public int compare(Student a, Student b){
        if(a.b==b.b) return (int)b.a-(int)a.a;
        return   a.b-b.b;}
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package Round547;

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;

/**
 *
 * @author Hemant Dhanuka
 */
public class F1 {

    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

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

        public Reader(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[64]; // line length
            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();
        }
    }

    public static void main(String[] args) throws IOException {
  //    Scanner s=new Scanner(System.in);
     Reader s=new Reader();
    int n=s.nextInt();

        int a[]=new int[n];

        for(int i=0;i<n;i++){
            a[i]=s.nextInt();
        }

        Map<Long,PriorityQueue<Node>> map=new HashMap();

        for(int i=0;i<n;i++){
            long sum=0;
            for(int j=i;j<n;j++){
                sum=sum+a[j];
                PriorityQueue<Node> pq=map.get(sum);
                if(pq==null){
                    pq=new PriorityQueue();
                    map.put(sum, pq);
                }
                pq.add(new Node(i,j));
            }

        }

        Set<Long> keys=map.keySet();

        Iterator<Long> itr=keys.iterator();
        int max=0;
        int solbackDp[]=null;
        Node solA[]=new Node[0];
        while(itr.hasNext()){
           Long sum=itr.next();
           PriorityQueue<Node> pq1=map.get(sum);

           //Node rangelist[]=new  Node[pq1.size()+1];
            ArrayList<Node> rangelist=new ArrayList<>();
            rangelist.add(new Node(-1, -1));
            //int count=1;
            //rangelist[0]=new Node(-1,-1);
             Node last=rangelist.get(0);
            while(!pq1.isEmpty()){
                Node n1=pq1.poll();
                if(n1.l!=last.l){
                    rangelist.add(n1);
                    last=n1;
                }

           }
           int backTrack[]=new int[rangelist.size()];
           int dp[]=new int[rangelist.size()];
           Arrays.fill(dp, -1);
           int ans=fun(0,dp,rangelist,backTrack);
           if(ans>max){
               max=ans;
               solA=rangelist.toArray(solA);
               solbackDp=backTrack;
           }
        }

        System.out.println(max);

        int pos=0;
        while(solbackDp[pos]!=-1){
            pos=solbackDp[pos];
            System.out.println((solA[pos].l+1)+" "+(solA[pos].r+1));
        }
    }

    static int fun(int pos, int[] dp, ArrayList<Node> rangeList, int[] bactTrack){

        if(pos==rangeList.size()-1){
            bactTrack[pos]=-1;
            return 0;

        }

        if(dp[pos]!=-1){
            return dp[pos];
        }

        int i=pos+1;
        int maxAns=0;
        int nextPos=-1;
        for(;i<=rangeList.size()-1;i++){

            if(rangeList.get(i).l>rangeList.get(pos).r){
                int tempAns=1+fun(i, dp,rangeList, bactTrack);
                if(tempAns>maxAns){
                    maxAns=tempAns;
                    nextPos=i;
                }
            }
        }

        dp[pos]=maxAns;
        bactTrack[pos]=nextPos;
        return maxAns;

    }

    static class Node implements Comparable<Node>{
        int l;
        int r;

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

        @Override
        public int compareTo(Node o2) {
            if(this.l!=o2.l){
                return this.l-o2.l;
            } else{
                return this.r-o2.r;
            }
        }

    }
}


import java.util.*;
import java.io.*;
public class Solution1{

	static class Node{
		int start,end;
		Node(int start, int end){
			this.start=start;
			this.end=end;
		}
		public String toString(){
			return start+" "+end;
		}
	}

	public static void sameSumBlock(int a[],int n){
		HashMap<Long,ArrayList<Node>> map=new HashMap<>();

		long sum;
		for(int i=0;i<n;i++){
			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 Node(i+1, j+1) );
			}
		}

		//for(Map.Entry<Long,ArrayList<Node>> pair: map.entrySet())
			//System.out.println(pair.getKey()+" "+pair.getValue());

		int max=0;	LinkedList<Node> list=new LinkedList<>();
		for(Map.Entry<Long,ArrayList<Node>> pair: map.entrySet()){

			ArrayList<Node> arr=pair.getValue();
			Collections.sort(arr, (Node x, Node y)->{	return x.end-y.end;	});

			int count=0,end=0;
			LinkedList<Node> temp=new LinkedList<>();
			for(Node item: arr){
				if(end<item.start){
					end=item.end;
					count+=1;
					temp.add(new Node(item.start, item.end));
				}
			}

			if(count>max){
				max=count;
				list=temp;
			}
		}

		System.out.println(max);
		for(Node item: list)
			System.out.println(item.start+" "+item.end);
	}

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

		int n=in.nextInt();

		int a[]=new int[n];
		for(int i=0;i<n;i++)
			a[i]=in.nextInt();

		sameSumBlock(a,n);
	}
}


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) continue;
				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();

	}
}