/*Author: Satyajeet Singh, Delhi Technological University*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;

public class Main {
/*********************************************Constants******************************************/
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static long mod=(long)1e9+7;
    static long mod1=998244353;
    static boolean sieve[];
    static ArrayList<Integer> primes;
    static ArrayList<Long> factorial;
    static HashSet<Integer> graph[];
/****************************************Solutions Begins*****************************************/
    public static void main (String[] args) throws Exception {
        String st[]=br.readLine().split(" ");
        int n=Integer.parseInt(st[0]);
        long input[]=new long[n];
        st=br.readLine().split(" ");
        for(int i=0;i<n;i++){
            input[i]=Long.parseLong(st[i]);
        }
        HashMap<Long,ArrayList<Pair>> map=new HashMap<>();
        long pref[]=new long[n+1];
        pref[1]=input[0];
        for(int i=1;i<n;i++){
            pref[i+1]=pref[i]+input[i];
        }
        for(int i=0;i<n;i++){
            for(int j=i;j<n;j++){
                long sum=pref[j+1]-pref[i];
                if(!map.containsKey(sum)){
                    ArrayList<Pair> list=new ArrayList<>();
                    list.add(new Pair(i,j));
                    map.put(sum,list);
                }
                else{
                    ArrayList<Pair> list=map.get(sum);
                    list.add(new Pair(i,j));
                }
            }
        }
        ArrayList<Pair> ans=new ArrayList<>();
       // debug(map);
        for(long keys:map.keySet()){
            ArrayList<Pair> list=map.get(keys);
            Collections.sort(list,new PairComp());
            int nn=list.size();
            for(int j=0;j<=0;j++){
                ArrayList<Pair> cur=new ArrayList<>();
                cur.add(list.get(j));
                int lim=list.get(j).v;
                int i=j;
                while(i<nn){
                    if(list.get(i).u<=lim){
                        i++;
                    }
                    else{
                        cur.add(list.get(i));
                        lim=list.get(i).v;
                        i++;
                    }
                }
                if(ans.size()<cur.size()){
                    ans=cur;
                }
            }
        }
        out.println(ans.size());
        for(Pair p:ans){
            out.println(++p.u+" "+ ++p.v);
        }
/****************************************Solutions Ends**************************************************/
        out.flush();
        out.close();
    }
/****************************************Template Begins************************************************/
/***************************************Precision Printing**********************************************/
    static void printPrecision(double d){
        DecimalFormat ft = new DecimalFormat("0.00000000000000000");
        out.println(ft.format(d));
    }
/******************************************Graph*********************************************************/
    static void Makegraph(int n){
        graph=new HashSet[n];
        for(int i=0;i<n;i++){
            graph[i]=new HashSet<>();
        }
    }
    static void addEdge(int a,int b){
        graph[a].add(b);
    }
/*********************************************PAIR********************************************************/
    static class PairComp implements Comparator<Pair>{
        public int compare(Pair p1,Pair p2){
            if(p1.v>p2.v){
                return 1;
            }
            else if(p1.v<p2.v){
                return -1;
            }
            else{
                return p1.u-p2.u;
            }
        }
    }
    static class Pair implements Comparable<Pair> {
        int u;
        int v;
        int index=-1;
        public Pair(int u, int v) {
            this.u = u;
            this.v = v;
        }

        public int hashCode() {
            int hu = (int) (u ^ (u >>> 32));
            int hv = (int) (v ^ (v >>> 32));
            return 31 * hu + hv;
        }

        public boolean equals(Object o) {
            Pair other = (Pair) o;
            return u == other.u && v == other.v;
        }

        public int compareTo(Pair other) {
            if(index!=other.index)
                return Long.compare(index, other.index);
            return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
        }

        public String toString() {
            return "[u=" + u + ", v=" + v + "]";
        }
    }

    static class PairCompL implements Comparator<Pairl>{
        public int compare(Pairl p1,Pairl p2){
            if(p1.v>p2.v){
                return -1;
            }
            else if(p1.v<p2.v){
                return 1;
            }
            else{
                return 0;
            }
        }
    }
    static class Pairl implements Comparable<Pair> {
            long u;
            long v;
            int index=-1;
            public Pairl(long u, long v) {
                this.u = u;
                this.v = v;
            }

            public int hashCode() {
                int hu = (int) (u ^ (u >>> 32));
                int hv = (int) (v ^ (v >>> 32));
                return 31 * hu + hv;
            }

            public boolean equals(Object o) {
                Pair other = (Pair) o;
                return u == other.u && v == other.v;
            }

            public int compareTo(Pair other) {
                if(index!=other.index)
                    return Long.compare(index, other.index);
                return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
            }

            public String toString() {
                return "[u=" + u + ", v=" + v + "]";
            }
        }
/*****************************************DEBUG***********************************************************/
    public static void debug(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
/************************************MODULAR EXPONENTIATION***********************************************/
    static long modulo(long a,long b,long c) {
        long x=1;
        long y=a;
        while(b > 0){
            if(b%2 == 1){
                x=(x*y)%c;
            }
            y = (y*y)%c; // squaring the base
            b /= 2;
        }
        return  x%c;
    }
/********************************************GCD**********************************************************/
    static long gcd(long x, long y)
    {
        if(x==0)
            return y;
        if(y==0)
            return x;
        long r=0, a, b;
        a = (x > y) ? x : y; // a is greater number
        b = (x < y) ? x : y; // b is smaller number
        r = b;
        while(a % b != 0)
        {
            r = a % b;
            a = b;
            b = r;
        }
        return r;
    }
/******************************************SIEVE**********************************************************/
    static void sieveMake(int n){
        sieve=new boolean[n];
        Arrays.fill(sieve,true);
        sieve[0]=false;
        sieve[1]=false;
        for(int i=2;i*i<n;i++){
            if(sieve[i]){
                for(int j=i*i;j<n;j+=i){
                    sieve[j]=false;
                }
            }
        }
        primes=new ArrayList<Integer>();
        for(int i=0;i<n;i++){
            if(sieve[i]){
                primes.add(i);
            }
        }
    }
/********************************************End***********************************************************/
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        F2BlokiRavnoiSummiUslozhnennayaRedakciya solver = new F2BlokiRavnoiSummiUslozhnennayaRedakciya();
        solver.solve(1, in, out);
        out.close();
    }

    static class F2BlokiRavnoiSummiUslozhnennayaRedakciya {

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

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

            int max = 0;
            int maxS = 0;
            for (int i = 0; i < n; i++) {
                for (int h = i; h >= 0; h--) {
                    int s = sum[i];
                    if (h > 0) {
                        s -= sum[h - 1];
                    }
                    blocks.putIfAbsent(s, new ArrayList<>());
                    List<Pair<Integer, Integer>> l = blocks.get(s);
                    if (l.isEmpty() || l.get(l.size() - 1).sc < h) {
                        l.add(new Pair<>(h, i));
                    }
                    if (l.size() > max) {
                        max = l.size();
                        maxS = s;
                    }
                }
            }

            out.println(max);
            for (int i = 0; i < max; i++) {
                out.println(String.format("%d %d", blocks.get(maxS).get(i).fs + 1, blocks.get(maxS).get(i).sc + 1));
            }
        }
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

    static class Pair<T, K> {

        T fs;
        K sc;

        public Pair(T fs, K sc) {
            this.fs = fs;
            this.sc = sc;
        }
    }
}


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

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

    static class F2SameSumBlocksHard {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            int[] tab = new int[n];
            int[] s = new int[n];
            for (int i = 0; i < n; i++) {
                tab[i] = sc.nextInt();
                if (i > 0)
                    s[i] = s[i - 1] + tab[i];
                else
                    s[0] = tab[0];
            }
            HashMap<Integer, F2SameSumBlocksHard.Pair> sums = new HashMap<>();
            F2SameSumBlocksHard.Pair p;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j <= i; j++) {
                    if (j > 0) {
                        if (sums.get(s[i] - s[j - 1]) != null) {
                            if (sums.get(s[i] - s[j - 1]).last < j) {
                                sums.get(s[i] - s[j - 1]).sum++;
                                sums.get(s[i] - s[j - 1]).last = i;
                            }
                        } else {
                            p = new F2SameSumBlocksHard.Pair();
                            p.sum = 1;
                            p.last = i;
                            sums.put(s[i] - s[j - 1], p);
                        }
                    } else {
                        if (sums.get(s[i]) != null) {
                            if (sums.get(s[i]).last < j) {
                                sums.get(s[i]).sum++;
                                sums.get(s[i]).last = i;
                            }
                        } else {
                            p = new F2SameSumBlocksHard.Pair();
                            p.sum = 1;
                            p.last = i;
                            sums.put(s[i], p);
                        }
                    }
                }
            }

            Iterator<Map.Entry<Integer, F2SameSumBlocksHard.Pair>> it = sums.entrySet().iterator();
            Map.Entry<Integer, F2SameSumBlocksHard.Pair> t;
            int maxsum = 0;
            int cnt = 0;
            while (it.hasNext()) {
                t = it.next();
                if (t.getValue().sum > cnt) {
                    maxsum = t.getKey();
                    cnt = t.getValue().sum;
                }
            }

            out.println(cnt);
            int start = 0;
            for (int i = 0; i < n; i++) {
                for (int j = start; j <= i; j++) {
                    if (j > 0) {
                        if (s[i] - s[j - 1] == maxsum) {
                            out.println((j + 1) + " " + (i + 1));
                            start = i + 1;
                            break;
                        }
                    } else {
                        if (s[i] == maxsum) {
                            out.println((j + 1) + " " + (i + 1));
                            start = i + 1;
                            break;
                        }
                    }
                }
            }

        }

        static class Pair {
            int sum;
            int last;

        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

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

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

    }
}


//package com.example.programming;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class CodeforcesProblems {

    static class Pair {
        public Pair(int key, int val) {
            this.key = key;
            this.val = val;
        }
        int key;
        int val;
    }

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

        //String[] strings = br.readLine().split(" ");
        int n = Integer.parseInt(br.readLine());

        String[] strings = br.readLine().split(" ");
        int[] arr = new int[n];
        for(int i = 0; i<n; i++) {
            arr[i] = Integer.parseInt(strings[i]);
        }

        HashMap<Integer, ArrayList<Pair>> segments = new HashMap<>();
        for(int r = 0; r<arr.length; r++) {
            int sum = 0;
            for(int l = r; l>=0; l--) {
                sum += arr[l];
                ArrayList<Pair> pairs = segments.get(sum);
                if(pairs == null) {
                    pairs = new ArrayList<>();
                    segments.put(sum, pairs);
                }
                pairs.add(new Pair(l, r));
            }
        }

        int res = 0;
        ArrayList<Pair> result = new ArrayList<>();
        for(ArrayList<Pair> pairs: segments.values()) {
            ArrayList<Pair> temp = new ArrayList<>();
            int count = 0;
            int r = -1;
            for(Pair p : pairs) {
                if(p.key>r) {
                    count++;
                    temp.add(p);
                    r = p.val;
                }
            }
            if(count>res) {
                res = count;
                result = temp;
            }
        }
        System.out.println(res);
        StringBuilder sb = new StringBuilder();
        for(Pair p : result){
            sb.append(p.key+1).append(' ').append(p.val+1).append('\n');
        }
        System.out.print(sb);
    }
}


import javax.print.attribute.standard.PrinterMessageFromOperator;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        new Main().run();}

//    int[] h,ne,to,wt;
//    int ct = 0;
//    int n;
//    void graph(int n,int m){
//        h = new int[n];
//        Arrays.fill(h,-1);
////        sccno = new int[n];
////        dfn = new int[n];
////        low = new int[n];
////        iscut = new boolean[n];
//        ne = new int[2*m];
//        to = new int[2*m];
//        wt = new int[2*m];
//        ct = 0;
//    }
//    void add(int u,int v,int w){
//        to[ct] = v;
//        ne[ct] = h[u];
//        wt[ct] = w;
//        h[u] = ct++;
//    }
//
//    int color[],dfn[],low[],stack[] = new int[1000000],cnt[];
//    int sccno[];
//    boolean iscut[];
//    int time = 0,top = 0;
//    int scc_cnt = 0;
//
//    // 有向图的强连通分量
//    void tarjan(int u) {
//        low[u] = dfn[u]= ++time;
//        stack[top++] = u;
//        for(int i=h[u];i!=-1;i=ne[i]) {
//            int v = to[i];
//            if(dfn[v]==0) {
//                tarjan(v);
//                low[u]=Math.min(low[u],low[v]);
//            } else if(sccno[v]==0) {
//                // dfn>0 but sccno==0, means it's in current stack
//                low[u]=Math.min(low[u],low[v]);
//            }
//        }
//
//        if(dfn[u]==low[u]) {
//            sccno[u] = ++scc_cnt;
//            while(stack[top-1]!=u) {
//                sccno[stack[top-1]] = scc_cnt;
//                --top;
//            }
//            --top;
//        }
//    }
//
//    //缩点, topology sort
//    int[] h1,to1,ne1;
//    int ct1 = 0;
//    void point(){
//        for(int i=0;i<n;i++) {
//            if(dfn[i]==0) tarjan(i);//有可能图不连通，所以要循环判断。
//        }
//        // 入度
//        int du[] = new int[scc_cnt+1];
//        h1 = new int[scc_cnt+1];
//        Arrays.fill(h1, -1);
//        to1 = new int[scc_cnt*scc_cnt];
//        ne1 = new int[scc_cnt*scc_cnt];
//        // scc_cnt 个点
//
//        for(int i=1;i<=n;i++) {
//            for(int j=h[i]; j!=-1; j=ne[j]) {
//                int y = to[j];
//                if(sccno[i] != sccno[y]) {
//                    // add(sccno[i],sccno[y]);  // 建新图
//                    to1[ct1] = sccno[y];
//                    ne1[ct1] = h[sccno[i]];
//                    h[sccno[i]] = ct1++;
//                    du[sccno[y]]++; //存入度
//                }
//            }
//        }
//
//        int q[] = new int[100000];
//        int end = 0;
//        int st = 0;
//        for(int i=1;i<=scc_cnt;++i){
//            if(du[i]==0){
//                q[end++] = i;
//            }
//        }
//
//        int dp[] = new int[scc_cnt+1];
//        while(st<end){
//            int cur = q[st++];
//            for(int i=h1[cur];i!=-1;i=ne1[i]){
//                int y = to[i];
//                // dp[y] += dp[cur];
//                if(--du[y]==0){
//                    q[end++] = y;
//                }
//            }
//        }
//    }
//
//
//
//
//    int fa[];
//    int faw[];
//
//    int dep = -1;
//    int pt = 0;
//    void go(int rt,int f,int dd){
//
//        int p = 0;
//        stk[p] = rt;
//        lk[p] = 0;
//        fk[p] = f;p++;
//        while(p>0) {
//            int cur = stk[p - 1];
//            int fp = fk[p - 1];
//            int ll = lk[p - 1];
//            p--;
//
//
//            if (ll > dep) {
//                dep = ll;
//                pt = cur;
//            }
//            for (int i = h[cur]; i != -1; i = ne[i]) {
//                int v = to[i];
//                if (fp == v) continue;
//
//                stk[p] = v;
//                lk[p] = ll + wt[i];
//                fk[p] = cur;
//                p++;
//            }
//        }
//    }
//    int pt1 = -1;
//    void go1(int rt,int f,int dd){
//
//        int p = 0;
//        stk[p] = rt;
//        lk[p] = 0;
//        fk[p] = f;p++;
//        while(p>0) {
//            int cur = stk[p - 1];
//            int fp = fk[p - 1];
//            int ll = lk[p - 1];
//            p--;
//
//
//            if (ll > dep) {
//                dep = ll;
//                pt1 = cur;
//            }
//
//            fa[cur] = fp;
//            for (int i = h[cur]; i != -1; i = ne[i]) {
//                int v = to[i];
//                if (v == fp) continue;
//                faw[v] = wt[i];
//                stk[p] = v;
//                lk[p] = ll + wt[i];
//                fk[p] = cur;
//                p++;
//            }
//        }
//    }
//
//    int r = 0;
//    int stk[] = new int[301];
//    int fk[] = new int[301];
//    int lk[] = new int[301];
//    void ddfs(int rt,int t1,int t2,int t3,int l){
//
//
//        int p = 0;
//        stk[p] = rt;
//        lk[p] = 0;
//        fk[p] = t3;p++;
//        while(p>0){
//            int cur = stk[p-1];
//            int fp = fk[p-1];
//            int ll = lk[p-1];
//            p--;
//            r = Math.max(r,ll);
//            for(int i=h[cur];i!=-1;i=ne[i]){
//                int v = to[i];
//                if(v==t1||v==t2||v==fp) continue;
//                stk[p] = v;
//                lk[p] = ll+wt[i];
//                fk[p] = cur;p++;
//            }
//        }
//
//
//
//    }

    static long mul(long a, long b, long p)
    {
        long res=0,base=a;
        while(b>0)
        {
            if((b&1L)>0)
                res=(res+base)%p;
            base=(base+base)%p;
            b>>=1;
        }
        return res;
    }

    static long mod_pow(long k,long n,long p){
        long res = 1L;
        long temp = k;
        while(n!=0L){
            if((n&1L)==1L){
                res = (res*temp)%p;
            }
            temp = (temp*temp)%p;
            n = n>>1L;
        }
        return res%p;
    }
    int ct = 0;
    int f[]  =new int[200001];
    int b[]  =new int[200001];
    int str[]  =new int[200001];

    void go(int rt,List<Integer> g[]){
        str[ct] = rt;
        f[rt] = ct;
        for(int cd:g[rt]){
            ct++;
            go(cd,g);
        }
        b[rt] = ct;
    }
    int add =0;

    void go(int rt,int sd,int k,List<Integer> g[],int n){
        if(add>n) {
            return;
        }

        Queue<Integer> q =new LinkedList<>();
        q.offer(rt);
        for(int i=1;i<=sd;++i){
            int sz =q.size();
            if(sz==0) break;
            int f = (i==1?2:1);
            while(sz-->0){
                int cur = q.poll();
                for(int j=0;j<k-f;++j){
                    q.offer(add);
                    g[cur].add(add);add++;
                    if(add==n+1){
                        return;
                    }
                }
            }
        }

    }

    void solve() {

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

        Map<Integer,List<int[]>> mp = new HashMap<>();
        for(int i=0;i<n;++i) {
            for (int j = i; j>=0; --j) {
                int v = s[i+1]-s[j];
                if(!mp.containsKey(v)){
                    mp.put(v, new ArrayList<>());
                }
                mp.get(v).add(new int[]{j,i});
            }
        }
        int all = 0;int vv = -1;
        for(int v:mp.keySet()){
            List<int[]> r = mp.get(v);
            int sz = r.size();int c = 0;
            int ri = -2000000000;
            for(int j=0;j<sz;++j){
                if(r.get(j)[0]>ri){
                    ri = r.get(j)[1];c++;
                }
            }
            if(c>all){
                all = c;
                vv = v;
            }
        }
        println(all);
        List<int[]> r = mp.get(vv);
        int sz = r.size();int c = 0;
        int ri = -2000000000;
        for(int j=0;j<sz;++j){
            if(r.get(j)[0]>ri){
                ri = r.get(j)[1];println((1+r.get(j)[0])+" "+(1+r.get(j)[1]));
            }
        }

        //N , M , K , a , b , c , d . 其中N , M是矩阵的行列数；K 是上锁的房间数目，(a, b)是起始位置，(c, d)是出口位置

//        int n = ni();
//        int m = ni();
//        int k = ni();
//        int a = ni();
//        int b = ni();
//        int c = ni();
//        int d = ni();
//
//
//        char cc[][] = nm(n,m);
//        char keys[][] = new char[n][m];
//
//        char ky = 'a';
//        for(int i=0;i<k;++i){
//            int x = ni();
//            int y = ni();
//            keys[x][y] = ky;
//            ky++;
//        }
//        int f1[] = {a,b,0};
//
//        int dd[][] = {{0,1},{0,-1},{1,0},{-1,0}};
//
//        Queue<int[]> q =  new LinkedList<>();
//        q.offer(f1);
//        int ts = 1;
//
//        boolean vis[][][] = new boolean[n][m][33];
//
//        while(q.size()>0){
//            int sz = q.size();
//            while(sz-->0) {
//                int cur[] = q.poll();
//                vis[cur[0]][cur[1]][cur[2]] = true;
//
//                int x = cur[0];
//                int y = cur[1];
//
//                for (int u[] : dd) {
//                       int lx = x +  u[0];
//                       int ly = y +  u[1];
//                       if (lx >= 0 && ly >= 0 && lx < n && ly < m && (cc[lx][ly] != '#')&&!vis[lx][ly][cur[2]]){
//                            char ck =cc[lx][ly];
//                            if(ck=='.'){
//                                if(lx==c&&ly==d){
//                                    println(ts); return;
//                                }
//                                if(keys[lx][ly]>='a'&&keys[lx][ly]<='z') {
//                                    int cao = cur[2] | (1 << (keys[lx][ly] - 'a'));
//                                    q.offer(new int[]{lx, ly, cao});
//                                    vis[lx][ly][cao] = true;
//                                }else {
//
//                                    q.offer(new int[]{lx, ly, cur[2]});
//                                }
//
//                            }else if(ck>='A'&&ck<='Z'){
//                                int g = 1<<(ck-'A');
//                                if((g&cur[2])>0){
//                                    if(lx==c&&ly==d){
//                                        println(ts); return;
//                                    }
//                                    if(keys[lx][ly]>='a'&&keys[lx][ly]<='z') {
//
//                                        int cao = cur[2] | (1 << (keys[lx][ly] - 'a'));
//                                        q.offer(new int[]{lx, ly, cao});
//                                        vis[lx][ly][cao] = true;;
//                                    }else {
//
//                                        q.offer(new int[]{lx, ly, cur[2]});
//                                    }
//                                }
//                            }
//                       }
//                }
//
//                }
//            ts++;
//        }
//        println(-1);

//        int n = ni();
//
//        HashSet<String> st = new HashSet<>();
//        HashMap<String,Integer> mp = new HashMap<>();
//
//
//        for(int i=0;i<n;++i){
//            String s  = ns();
//            int id= 1;
//            if(mp.containsKey(s)){
//                int u = mp.get(s);
//                id = u;
//
//            }
//
//            if(st.contains(s)) {
//
//                while (true) {
//                    String ts = s + id;
//                    if (!st.contains(ts)) {
//                        s = ts;
//                        break;
//                    }
//                    id++;
//                }
//                mp.put(s,id+1);
//            }else{
//                mp.put(s,1);
//            }
//            println(s);
//            st.add(s);
//
//        }

//        int t = ni();
//
//        for(int i=0;i<t;++i){
//            int n = ni();
//            long w[] = nal(n);
//
//            Map<Long,Long> mp = new HashMap<>();
//            PriorityQueue<long[]> q =new PriorityQueue<>((xx,xy)->{return Long.compare(xx[0],xy[0]);});
//
//            for(int j=0;j<n;++j){
//                q.offer(new long[]{w[j],0});
//                mp.put(w[j],mp.getOrDefault(w[j],0L)+1L);
//            }
//
//            while(q.size()>=2){
//                long f[] = q.poll();
//                long y1 = f[1];
//                if(y1==0){
//                    y1 = mp.get(f[0]);
//                    if(y1==1){
//                        mp.remove(f[0]);
//                    }else{
//                        mp.put(f[0],y1-1);
//                    }
//                }
//                long g[] = q.poll();
//                long y2 = g[1];
//                if(y2==0){
//                    y2 = mp.get(g[0]);
//                    if(y2==1){
//                        mp.remove(g[0]);
//                    }else{
//                        mp.put(g[0],y2-1);
//                    }
//                }
//                q.offer(new long[]{f[0]+g[0],2L*y1*y2});
//
//            }
//            long r[] = q.poll();
//            println(r[1]);
//
//
//
//
//        }
        //  int o= 9*8*7*6;
        //  println(o);

//       int t = ni();
//       for(int i=0;i<t;++i){
//           long a = nl();
//           int k  = ni();
//           if(k==1){
//               println(a);
//               continue;
//           }
//
//           int f = (int)(a%10L);
//           int s = 1;
//           int j = 0;
//           for(;j<30;j+=2){
//               int u = f-j;
//               if(u<0){
//                   u = 10+u;
//               }
//               s = u*s;
//               s = s%10;
//               if(s==k){
//                   break;
//               }
//           }
//
//           if(s==k) {
//               println(a - j - 2);
//           }else{
//               println(-1);
//           }
//
//
//
//
//       }

//     int m = ni();
//     h = new int[n];
//     to = new int[2*(n-1)];
//     ne = new int[2*(n-1)];
//     wt = new int[2*(n-1)];
//
//     for(int i=0;i<n-1;++i){
//         int u = ni()-1;
//         int v = ni()-1;
//
//     }
        //  long a[] = nal(n);

//        int n = ni();
//        int k = ni();
//        t1 = new long[200002];
//
//        int p[][] = new int[n][3];
//
//        for(int i=0;i<n;++i){
//            p[i][0]  = ni();
//            p[i][1]  = ni();
//            p[i][2]  = i+1;
//        }
//        Arrays.sort(p, new Comparator<int[]>() {
//            @Override
//            public int compare(int[] x, int[] y) {
//                if(x[1]!=y[1]){
//                    return Integer.compare(x[1],y[1]);
//                }
//                return Integer.compare(y[0], x[0]);
//            }
//        });
//
//        for(int i=0;i<n;++i){
//            int ck = p[i][0];
//
//        }

    }

//    int []h,to,ne,wt;

    long t1[];
    //    long t2[];
    void update(long[] t,int i,long v){
        for(;i<t.length;i+=(i&-i)){
            t[i] += v;
        }
    }
    long get(long[] t,int i){
        long s = 0;
        for(;i>0;i-=(i&-i)){
            s += t[i];
        }
        return s;
    }

    int equal_bigger(long t[],long v){
        int s=0,p=0;
        for(int i=Integer.numberOfTrailingZeros(Integer.highestOneBit(t.length));i>=0;--i) {
            if(p+(1<<i)< t.length && s + t[p+(1<<i)] < v){
                v -= t[p+(1<<i)];
                p |= 1<<i;
            }
        }
        return p+1;
    }

    static class S{
        int l = 0;
        int r = 0 ;
        long le = 0;
        long ri = 0;
        long tot = 0;
        long all = 0;

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

    static S a[];
    static int[] o;

    static void init(int[] f){
        o = f;
        int len = o.length;
        a = new S[len*4];
        build(1,0,len-1);
    }

    static void build(int num,int l,int r){
        S cur = new S(l,r);
        if(l==r){
            a[num] = cur;
            return;
        }else{
            int m = (l+r)>>1;
            int le = num<<1;
            int ri = le|1;
            build(le, l,m);
            build(ri, m+1,r);
            a[num] = cur;
            pushup(num, le, ri);
        }
    }

    //    static int query(int num,int l,int r){
//
//        if(a[num].l>=l&&a[num].r<=r){
//            return a[num].tot;
//        }else{
//            int m = (a[num].l+a[num].r)>>1;
//            int le = num<<1;
//            int ri = le|1;
//            pushdown(num, le, ri);
//            int ma = 1;
//            int mi = 100000001;
//            if(l<=m) {
//                int r1 = query(le, l, r);
//                ma = ma*r1;
//
//            }
//            if(r>m){
//                int r2 = query(ri, l, r);
//                ma = ma*r2;
//            }
//            return ma;
//        }
//    }
    static long dd = 10007;
    static void update(int num,int l,long v){
        if(a[num].l==a[num].r){
            a[num].le = v%dd;
            a[num].ri = v%dd;
            a[num].all = v%dd;
            a[num].tot = v%dd;
        }else{
            int m = (a[num].l+a[num].r)>>1;
            int le = num<<1;
            int ri = le|1;
            pushdown(num, le, ri);
            if(l<=m){
                update(le,l,v);
            }
            if(l>m){
                update(ri,l,v);
            }
            pushup(num,le,ri);
        }
    }

    static void pushup(int num,int le,int ri){
        a[num].all = (a[le].all*a[ri].all)%dd;
        a[num].le = (a[le].le + a[le].all*a[ri].le)%dd;
        a[num].ri = (a[ri].ri + a[ri].all*a[le].ri)%dd;
        a[num].tot = (a[le].tot + a[ri].tot + a[le].ri*a[ri].le)%dd;

        //a[num].res[1] = Math.min(a[le].res[1],a[ri].res[1]);
    }
    static void pushdown(int num,int le,int ri){

    }

    int gcd(int a,int b){ return b==0?a: gcd(b,a%b);}
    InputStream is;PrintWriter out;
    void run() throws Exception {is = System.in;out = new PrintWriter(System.out);solve();out.flush();}
    private byte[] inbuf = new byte[2];
    public int lenbuf = 0, ptrbuf = 0;
    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {lenbuf = is.read(inbuf);} catch (IOException e) {throw new InputMismatchException();}
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];}
    private boolean isSpaceChar(int c) {return !(c >= 33 && c <= 126);}
    private int skip() {int b;while((b = readByte()) != -1 && isSpaceChar(b));return b;}
    private double nd() {return Double.parseDouble(ns());}
    private char nc() {return (char) skip();}
    private char ncc() {int b;while((b = readByte()) != -1 && !(b >= 32 && b <= 126));return (char)b;}
    private String ns() {int b = skip();StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);b = readByte(); }
        return sb.toString();}
    private char[] ns(int n) {char[] buf = new char[n];int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) { buf[p++] = (char) b;b = readByte(); }
        return n == p ? buf : Arrays.copyOf(buf, p);}
    private String nline() {int b = skip();StringBuilder sb = new StringBuilder();
        while (!isSpaceChar(b) || b == ' ') { sb.appendCodePoint(b);b = readByte(); }
        return sb.toString();}
    private char[][] nm(int n, int m) {char[][] a = new char[n][];for (int i = 0; i < n; i++) a[i] = ns(m);return a;}
    private int[] na(int n) {int[] a = new int[n];for (int i = 0; i < n; i++) a[i] = ni();return a;}
    private long[] nal(int n) { long[] a = new long[n];for (int i = 0; i < n; i++) a[i] = nl();return a;}
    private int ni() { int num = 0, b; boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')){};
        if (b == '-') { minus = true; b = readByte(); }
        while (true) {
            if (b >= '0' && b <= '9') num = (num << 3) + (num << 1) + (b - '0');
            else return minus ? -num : num;
            b = readByte();}}
    private long nl() { long num = 0; int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')){};
        if (b == '-') { minus = true; b = readByte(); }
        while (true) {
            if (b >= '0' && b <= '9')  num = num * 10 + (b - '0');
            else return minus ? -num : num;
            b = readByte();}}
    void print(Object obj){out.print(obj);}
    void println(Object obj){out.println(obj);}
    void println(){out.println();}
}


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

public class Solve6 {

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

    public void solve(PrintWriter pw) throws IOException {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        int[] a = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextInt();
        }
        HashMap<Integer, LinkedList<Pair<Integer, Integer>>> h = new HashMap();
        for (int i = 1; i <= n; i++) {
            int s = 0;
            for (int j = i; j >= 1; j--) {
                s += a[j];
                LinkedList<Pair<Integer, Integer>> l;
                if (!h.containsKey(s)) {
                    l = new LinkedList();
                } else {
                    l = h.get(s);
                }
                l.add(new Pair(j, i));
                h.put(s, l);
            }
        }
        LinkedList<Pair<Integer, Integer>>[] l = new LinkedList[h.size() + 1];
        for (int i = 1; i <= h.size(); i++) {
            l[i] = new LinkedList();
        }
        int k = 0, max = 0, index = 0;
        for (LinkedList<Pair<Integer, Integer>> temp : h.values()) {
            k++;
            int i = 0, size = 0;
            for (Pair<Integer, Integer> pair : temp) {
                if (pair.getKey() > i) {
                    i = pair.getValue();
                    l[k].add(pair);
                    size++;
                    if (size > max) {
                        max = size;
                        index = k;
                    }
                }
            }
        }
        pw.println(l[index].size());
        for (Pair<Integer, Integer> pair : l[index]) {
            pw.println(pair.getKey() + " " + pair.getValue());
        }
    }

    static class FastReader {

        StringTokenizer st;
        BufferedReader br;

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

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

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

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

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

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

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


/*
    Author: Anthony Ngene
    Created: 05/10/2020 - 14:12
*/

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

public class F {
// checks: 1. edge cases   2. overflow   3. possible errors (e.g 1/0, arr[out])   4. time/space complexity
    void solver() throws IOException {
        int n = in.intNext();
        int[] arr = in.nextIntArray(n);
        HashMap<Integer, Deque<Tuple>> subSum = new HashMap<>();

        Integer best = null;
        for (int i = 0; i < n; i++) {
            int total = 0;
            for (int j = i; j < n; j++) {
                total += arr[j];
                if (!subSum.containsKey(total)) subSum.put(total, new ArrayDeque<>());
                Deque<Tuple> rs = subSum.get(total);
                if (rs.size() > 0 && rs.peekLast().b > j) rs.pollLast();
                if (rs.size() == 0 || rs.peekLast().b < i)
                    rs.add(new Tuple(i, j));
                if (best == null || rs.size() > subSum.get(best).size())
                    best = total;
            }
        }
        Deque<Tuple> bestList = subSum.get(best);
        out.println(bestList.size());
        for (Tuple aa: bestList)
            out.pp(aa.a + 1, aa.b + 1);

    }

// Generated Code Below:
private static final FastWriter out = new FastWriter();
private static FastScanner in;
static ArrayList<Integer>[] adj;
private static long e97 = (long)1e9 + 7;
public static void main(String[] args) throws IOException {
    in = new FastScanner();
    new F().solver();
    out.close();
}

static class FastWriter {
    private static final int IO_BUFFERS = 128 * 1024;
    private final StringBuilder out;
    public FastWriter() { out = new StringBuilder(IO_BUFFERS); }
    public FastWriter p(Object object) { out.append(object); return this; }
    public FastWriter p(String format, Object... args) { out.append(String.format(format, args)); return this; }
    public FastWriter pp(Object... args) { for (Object ob : args) { out.append(ob).append(" ");  } out.append("\n"); return this; }
    public FastWriter pp(int[] args) { for (int ob : args) { out.append(ob).append(" ");  } out.append("\n"); return this; }
    public FastWriter pp(long[] args) { for (long ob : args) { out.append(ob).append(" ");  } out.append("\n"); return this; }
    public FastWriter pp(char[] args) { for (char ob : args) { out.append(ob).append(" ");  } out.append("\n"); return this; }
    public void println(long[] arr) { for(long e: arr) out.append(e).append(" "); out.append("\n"); }
    public void println(int[] arr) { for(int e: arr) out.append(e).append(" "); out.append("\n"); }
    public void println(char[] arr) { for(char e: arr) out.append(e).append(" "); out.append("\n"); }
    public void println(double[] arr) { for(double e: arr) out.append(e).append(" "); out.append("\n"); }
    public void println(boolean[] arr) { for(boolean e: arr) out.append(e).append(" "); out.append("\n"); }
    public <T>void println(T[] arr) { for(T e: arr) out.append(e).append(" "); out.append("\n"); }
    public void println(long[][] arr) {  for (long[] row: arr) out.append(Arrays.toString(row)).append("\n"); }
    public void println(int[][] arr) {  for (int[] row: arr) out.append(Arrays.toString(row)).append("\n"); }
    public void println(char[][] arr) {  for (char[] row: arr) out.append(Arrays.toString(row)).append("\n"); }
    public void println(double[][] arr) {  for (double[] row: arr) out.append(Arrays.toString(row)).append("\n"); }
    public <T>void println(T[][] arr) {  for (T[] row: arr) out.append(Arrays.toString(row)).append("\n"); }
    public FastWriter println(Object object) { out.append(object).append("\n"); return this; }
    public void toFile(String fileName) throws IOException {
        BufferedWriter writer = new BufferedWriter(new FileWriter(fileName));
        writer.write(out.toString());
        writer.close();
    }
    public void close() throws IOException { System.out.print(out); }
}
static class FastScanner {
    private InputStream sin = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(){}
    public FastScanner(String filename) throws FileNotFoundException {
        File file = new File(filename);
        sin = new FileInputStream(file);
    }
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = sin.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long longNext() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b) || b == ':'){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int intNext() {
        long nl = longNext();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double doubleNext() { return Double.parseDouble(next());}
    public long[] nextLongArray(final int n){
        final long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = longNext();
        return a;
    }
    public int[] nextIntArray(final int n){
        final int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = intNext();
        return a;
    }
    public double[] nextDoubleArray(final int n){
        final double[] a = new double[n];
        for (int i = 0; i < n; i++)
            a[i] = doubleNext();
        return a;
    }
    public ArrayList<Integer>[] getAdj(int n) {
        ArrayList<Integer>[] adj = new ArrayList[n + 1];
        for (int i = 1; i <= n; i++) adj[i] = new ArrayList<>();
        return adj;
    }
    public ArrayList<Integer>[] adjacencyList(int nodes, int edges) throws IOException {
        return adjacencyList(nodes, edges, false);
    }
    public ArrayList<Integer>[] adjacencyList(int nodes, int edges, boolean isDirected) throws IOException {
        adj = getAdj(nodes);
        for (int i = 0; i < edges; i++) {
            int a = intNext(), b = intNext();
            adj[a].add(b);
            if (!isDirected) adj[b].add(a);
        }
        return adj;
    }
}
static class u {
    public static int upperBound(long[] array, long obj) {
        int l = 0, r = array.length - 1;
        while (r - l >= 0) {
            int c = (l + r) / 2;
            if (obj < array[c]) {
                r = c - 1;
            } else {
                l = c + 1;
            }
        }
        return l;
    }
    public static int upperBound(ArrayList<Long> array, long obj) {
        int l = 0, r = array.size() - 1;
        while (r - l >= 0) {
            int c = (l + r) / 2;
            if (obj < array.get(c)) {
                r = c - 1;
            } else {
                l = c + 1;
            }
        }
        return l;
    }
    public static int lowerBound(long[] array, long obj) {
        int l = 0, r = array.length - 1;
        while (r - l >= 0) {
            int c = (l + r) / 2;
            if (obj <= array[c]) {
                r = c - 1;
            } else {
                l = c + 1;
            }
        }
        return l;
    }
    public static int lowerBound(ArrayList<Long> array, long obj) {
        int l = 0, r = array.size() - 1;
        while (r - l >= 0) {
            int c = (l + r) / 2;
            if (obj <= array.get(c)) {
                r = c - 1;
            } else {
                l = c + 1;
            }
        }
        return l;
    }
    static <T> T[][] deepCopy(T[][] matrix) { return Arrays.stream(matrix).map(el -> el.clone()).toArray($ -> matrix.clone()); }
    static int[][] deepCopy(int[][] matrix) { return Arrays.stream(matrix).map(int[]::clone).toArray($ -> matrix.clone()); }
    static long[][] deepCopy(long[][] matrix) { return Arrays.stream(matrix).map(long[]::clone).toArray($ -> matrix.clone()); }
    private static void sort(int[][] arr){ Arrays.sort(arr, Comparator.comparingDouble(o -> o[0])); }
    private static void sort(long[][] arr){ Arrays.sort(arr, Comparator.comparingDouble(o -> o[0])); }
    private static <T>void rSort(T[] arr) { Arrays.sort(arr, Collections.reverseOrder()); }
    private static void customSort(int[][] arr) {
        Arrays.sort(arr, new Comparator<int[]>() {
            public int compare(int[] a, int[] b) {
                if (a[0] == b[0]) return Integer.compare(a[1], b[1]);
                return Integer.compare(a[0], b[0]);
            }
        });
    }
    public static int[] swap(int[] arr, int left, int right) {
        int temp = arr[left];
        arr[left] = arr[right];
        arr[right] = temp;
        return arr;
    }
    public static char[] swap(char[] arr, int left, int right) {
        char temp = arr[left];
        arr[left] = arr[right];
        arr[right] = temp;
        return arr;
    }
    public static int[] reverse(int[] arr, int left, int right) {
        while (left < right) {
            int temp = arr[left];
            arr[left++] = arr[right];
            arr[right--] = temp;
        }
        return arr;
    }
    public static boolean findNextPermutation(int[] data) {
        if (data.length <= 1) return false;
        int last = data.length - 2;
        while (last >= 0) {
            if (data[last] < data[last + 1]) break;
            last--;
        }
        if (last < 0) return false;
        int nextGreater = data.length - 1;
        for (int i = data.length - 1; i > last; i--) {
            if (data[i] > data[last]) {
                nextGreater = i;
                break;
            }
        }
        data = swap(data, nextGreater, last);
        data = reverse(data, last + 1, data.length - 1);
        return true;
    }
    public static int biSearch(int[] dt, int target){
        int left=0, right=dt.length-1;
        int mid=-1;
        while(left<=right){
            mid = (right+left)/2;
            if(dt[mid] == target) return mid;
            if(dt[mid] < target) left=mid+1;
            else right=mid-1;
        }
        return -1;
    }
    public static int biSearchMax(long[] dt, long target){
        int left=-1, right=dt.length;
        int mid=-1;

        while((right-left)>1){
            mid = left + (right-left)/2;
            if(dt[mid] <= target) left=mid;
            else right=mid;
        }
        return left;
    }
    public static int biSearchMaxAL(ArrayList<Integer> dt, long target){
        int left=-1, right=dt.size();
        int mid=-1;

        while((right-left)>1){
            mid = left + (right-left)/2;
            if(dt.get(mid) <= target) left=mid;
            else right=mid;
        }
        return left;
    }
    private static <T>void fill(T[][] ob, T res){for(int i=0;i<ob.length; i++){ for(int j=0; j<ob[0].length; j++){  ob[i][j] = res; }}}
    private static void fill(boolean[][] ob,boolean res){for(int i=0;i<ob.length; i++){ for(int j=0; j<ob[0].length; j++){  ob[i][j] = res; }}}
    private static void fill(int[][] ob, int res){      for(int i=0; i<ob.length; i++){ for(int j=0; j<ob[0].length; j++){  ob[i][j] = res; }}}
    private static void fill(long[][] ob, long res){    for(int i=0; i<ob.length; i++){ for(int j=0; j<ob[0].length; j++){  ob[i][j] = res; }}}
    private static void fill(char[][] ob, char res){    for(int i=0; i<ob.length; i++){ for(int j=0; j<ob[0].length; j++){  ob[i][j] = res; }}}
    private static void fill(double[][] ob, double res){for(int i=0; i<ob.length; i++){ for(int j=0; j<ob[0].length; j++){  ob[i][j] = res; }}}
    private static void fill(int[][][] ob,int res){for(int i=0;i<ob.length;i++){for(int j=0;j<ob[0].length;j++){for(int k=0;k<ob[0][0].length;k++){ob[i][j][k]=res;}}}}
    private static void fill(long[][][] ob,long res){for(int i=0;i<ob.length;i++){for(int j=0;j<ob[0].length;j++){for(int k=0;k<ob[0][0].length;k++){ob[i][j][k]=res;}}}}
    private static <T>void fill(T[][][] ob,T res){for(int i=0;i<ob.length;i++){for(int j=0;j<ob[0].length;j++){for(int k=0;k<ob[0][0].length;k++){ob[i][j][k]=res;}}}}
    private static void fill_parent(int[] ob){ for(int i=0; i<ob.length; i++) ob[i]=i; }
    private static boolean same3(long a, long b, long c){
        if(a!=b) return false;
        if(b!=c) return false;
        if(c!=a) return false;
        return true;
    }
    private static boolean dif3(long a, long b, long c){
        if(a==b) return false;
        if(b==c) return false;
        if(c==a) return false;
        return true;
    }
    private static double hypotenuse(double a, double b){
        return Math.sqrt(a*a+b*b);
    }
    private static long factorial(int n) {
        long ans=1;
        for(long i=n; i>0; i--){ ans*=i; }
        return ans;
    }
    private static long facMod(int n, long mod) {
        long ans=1;
        for(long i=n; i>0; i--) ans = (ans * i) % mod;
        return ans;
    }
    private static long lcm(long m, long n){
        long ans = m/gcd(m,n);
        ans *= n;
        return ans;
    }
    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
    private static boolean isPrime(long a){
        if(a==1) return false;
        for(int i=2; i<=Math.sqrt(a); i++){  if(a%i == 0) return false;  }
        return true;
    }
    static long modInverse(long a, long mod) {
    /* Fermat's little theorem: a^(MOD-1) => 1
    Therefore (divide both sides by a): a^(MOD-2) => a^(-1) */
        return binpowMod(a, mod - 2, mod);
    }
    static long binpowMod(long a, long b, long mod) {
        long res = 1;
        while (b > 0) {
            if (b % 2 == 1) res = (res * a) % mod;
            a = (a * a) % mod;
            b /= 2;
        }
        return res;
    }
    private static int getDigit2(long num){
        long cf = 1;    int d=0;
        while(num >= cf){   d++;    cf = 1<<d;  }
        return d;
    }
    private static int getDigit10(long num){
        long cf = 1;    int d=0;
        while(num >= cf){   d++;    cf*=10;     }
        return d;
    }
    private static boolean isInArea(int y, int x, int h, int w){
        if(y<0) return false;
        if(x<0) return false;
        if(y>=h) return false;
        if(x>=w) return false;
        return true;
    }
    private static ArrayList<Integer> generatePrimes(int n) {
        int[] lp = new int[n + 1];
        ArrayList<Integer> pr = new ArrayList<>();
        for (int i = 2; i <= n; ++i) {
            if (lp[i] == 0) {
                lp[i] = i;
                pr.add(i);
            }
            for (int j = 0; j < pr.size() && pr.get(j) <= lp[i] && i * pr.get(j) <= n; ++j) {
                lp[i * pr.get(j)] = pr.get(j);
            }
        }
        return pr;
    }
    static long nPrMod(int n, int r, long MOD) {
        long res = 1;
        for (int i = (n - r + 1); i <= n; i++) {
            res = (res * i) % MOD;
        }
        return res;
    }
    static long nCr(int n, int r) {
        if (r > (n - r))
            r = n - r;
        long ans = 1;
        for (int i = 1; i <= r; i++) {
            ans *= n;
            ans /= i;
            n--;
        }
        return ans;
    }
    static long nCrMod(int n, int r, long MOD) {
        long rFactorial = nPrMod(r, r, MOD);
        long first = nPrMod(n, r, MOD);
        long second = binpowMod(rFactorial, MOD-2, MOD);
        return  (first * second) % MOD;
    }
    static void printBitRepr(int n) {
        StringBuilder res = new StringBuilder();
        for (int i = 0; i < 32; i++) {
            int mask = (1 << i);
            res.append((mask & n) == 0 ? "0" : "1");
        }
        out.println(res);
    }
    static String bitString(int n) {return Integer.toBinaryString(n);}
    static int setKthBitToOne(int n, int k) { return (n | (1 << k)); } // zero indexed
    static int setKthBitToZero(int n, int k) { return (n & ~(1 << k)); }
    static int invertKthBit(int n, int k) { return (n ^ (1 << k)); }
    static boolean isPowerOfTwo(int n) { return (n & (n - 1)) == 0; }
    static HashMap<Character, Integer> counts(String word) {
        HashMap<Character, Integer> counts = new HashMap<>();
        for (int i = 0; i < word.length(); i++) counts.merge(word.charAt(i), 1, Integer::sum);
        return counts;
    }
    static HashMap<Integer, Integer> counts(int[] arr) {
        HashMap<Integer, Integer> counts = new HashMap<>();
        for (int value : arr) counts.merge(value, 1, Integer::sum);
        return counts;
    }
    static HashMap<Long, Integer> counts(long[] arr) {
        HashMap<Long, Integer> counts = new HashMap<>();
        for (long l : arr) counts.merge(l, 1, Integer::sum);
        return counts;
    }
    static HashMap<Character, Integer> counts(char[] arr) {
        HashMap<Character, Integer> counts = new HashMap<>();
        for (char c : arr) counts.merge(c, 1, Integer::sum);
        return counts;
    }
    static long hash(int x, int y) {
        return x* 1_000_000_000L +y;
    }
    static final Random random = new Random();
    static void sort(int[] a) {
        int n = a.length;// shuffle, then sort
        for (int i = 0; i < n; i++) {
            int oi = random.nextInt(n), temp = a[oi];
            a[oi] = a[i];
            a[i] = temp;
        }
        Arrays.sort(a);
    }
    static void sort(long[] arr) {
        shuffleArray(arr);
        Arrays.sort(arr);
    }
    static void shuffleArray(long[] arr) {
        int n = arr.length;
        for(int i=0; i<n; ++i){
            long tmp = arr[i];
            int randomPos = i + random.nextInt(n-i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }
    }
}
static class Tuple implements Comparable<Tuple> {
    int a;
    int b;
    int c;
    public Tuple(int a, int b) {
        this.a = a;
        this.b = b;
        this.c = 0;
    }
    public Tuple(int a, int b, int c) {
        this.a = a;
        this.b = b;
        this.c = c;
    }
    public int getA() { return a; }
    public int getB() { return b; }
    public int getC() { return c; }
    public int compareTo(Tuple other) {
        if (this.a == other.a) {
            if (this.b == other.b) return Long.compare(this.c, other.c);
            return Long.compare(this.b, other.b);
        }
        return Long.compare(this.a, other.a);
    }
    @Override
    public int hashCode() { return Arrays.deepHashCode(new Integer[]{a, b, c}); }
    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Tuple)) return false;
        Tuple pairo = (Tuple) o;
        return (this.a == pairo.a && this.b == pairo.b && this.c == pairo.c);
    }
    @Override
    public String toString() { return String.format("(%d %d %d)  ", this.a, this.b, this.c); }
}
private static int abs(int a){  return (a>=0) ? a: -a;  }
private static int min(int... ins){ int min = ins[0]; for(int i=1; i<ins.length; i++){ if(ins[i] < min) min = ins[i]; } return min; }
private static int max(int... ins){ int max = ins[0]; for(int i=1; i<ins.length; i++){ if(ins[i] > max) max = ins[i]; } return max; }
private static int sum(int... ins){ int total = 0; for (int v : ins) { total += v; } return total; }
private static long abs(long a){    return (a>=0) ? a: -a;  }
private static long min(long... ins){ long min = ins[0]; for(int i=1; i<ins.length; i++){ if(ins[i] < min) min = ins[i]; } return min; }
private static long max(long... ins){ long max = ins[0]; for(int i=1; i<ins.length; i++){ if(ins[i] > max) max = ins[i]; } return max; }
private static long sum(long... ins){ long total = 0; for (long v : ins) { total += v; } return total; }
private static double abs(double a){    return (a>=0) ? a: -a;  }
private static double min(double... ins){ double min = ins[0]; for(int i=1; i<ins.length; i++){ if(ins[i] < min) min = ins[i]; } return min; }
private static double max(double... ins){ double max = ins[0]; for(int i=1; i<ins.length; i++){ if(ins[i] > max) max = ins[i]; } return max; }
private static double sum(double... ins){ double total = 0; for (double v : ins) { total += v; } return total; }

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class CF1141F {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] split = br.readLine().split(" ");
		int[] terms = new int[n];
		int[] sums = new int[n+1];
		for(int i=0; i<n; i++) {
			terms[i] = Integer.parseInt(split[i]);
			sums[i+1] = sums[i]+terms[i];
		}
		ArrayList<Block> blocks = new ArrayList<>();
		for(int i=0; i<n; i++)
			for(int j=i; j<n; j++){
				int s = sums[j+1]-sums[i];
				blocks.add(new Block(i, j, s));
			}
		Collections.sort(blocks);
		ArrayList<Block> best = new ArrayList<>();
		int i = 0;
		while(i<blocks.size()){
			int curSum = blocks.get(i).sum;
			ArrayList<Block> curBlocks = new ArrayList<>();
			while(i<blocks.size() && blocks.get(i).sum==curSum) curBlocks.add(blocks.get(i++));
			int[] memo = new int[curBlocks.size()+1];
			Arrays.fill(memo, -1);
			memo[curBlocks.size()] = 0;
			for(int j=curBlocks.size()-1; j>=0; j--){
				int idx = Collections.binarySearch(curBlocks, new Block(curBlocks.get(j).r+1, curBlocks.get(j).r+1, curBlocks.get(j).sum));
				if(idx<0) idx = -(idx+1);
				memo[j] = Math.max(memo[j+1], 1+memo[idx]);
			}
			if(memo[0]>best.size()){
				best = new ArrayList<>();
				int idx = 0;
				while(memo[idx]>=1){
					if(memo[idx]>memo[idx+1]) best.add(curBlocks.get(idx));
					idx++;
				}
			}
		}
		StringBuilder sb = new StringBuilder();
		sb.append(best.size()).append("\n");
		for(Block b : best){
			sb.append(b.l+1).append(" ").append(b.r+1).append("\n");
		}
		System.out.print(sb);
	}

	static class Block implements Comparable<Block>{
		int l, r, sum;

		Block(int a, int b, int c){
			l = a;
			r = b;
			sum = c;
		}

		@Override
		public int compareTo(Block o) {
			if(sum==o.sum){
				if(l==o.l) return r-o.r;
				return l-o.l;
			}
			return sum-o.sum;
		}
	}
}


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.StringTokenizer;
import java.io.BufferedReader;
import java.util.Comparator;
import java.util.Collections;
import java.io.InputStream;

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

    static class SameSumBlocks {
        int N;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            N = in.nextInt();
            int[] arr = new int[N];
            for (int i = 1; i <= N; i++) {
                arr[i - 1] = in.nextInt();
            }
            HashMap<Integer, ArrayList<Segment>> map = new HashMap<>();
            for (int i = 1; i <= N; i++) {
                int sum = 0;
                for (int j = i; j <= N; j++) {
                    sum += arr[j - 1];
                    map.putIfAbsent(sum, new ArrayList<>());
                    map.get(sum).add(new Segment(i, j));
                }
            }
            int resI = 0;
            int resVal = 0;
            int sum = 0;
            if (arr.length > 1 && arr[1] == -999) {
                for (int i = 11; i < 130; i++) {
                    sum += arr[i];
                }
            }
            for (int key : map.keySet()) {
                if (map.get(key).size() > resI) {
                    int next = largestNon(map.get(key));
                    if (next > resI) {
                        resVal = key;
                        resI = next;
                    }
                }
            }
            Pair res = largestNonOverlap(map.get(resVal));
            out.println(resI);
            for (int i = 0; i < resI; i++) {
                out.println(res.used.get(i).li + " " + res.used.get(i).ri);
            }
        }

        int largestNon(ArrayList<Segment> arr) {
            Collections.sort(arr, new Comparator<Segment>() {

                public int compare(Segment o1, Segment o2) {
                    return Integer.compare(o1.ri, o2.ri);
                }
            });
            SameSumBlocks.SegmentTree seg = new SameSumBlocks.SegmentTree(N + 1);
            for (int i = 0; i < arr.size(); i++) {
                seg.add(arr.get(i).ri, arr.get(i).ri, 1 + seg.query(0, arr.get(i).li - 1).mx);
            }
            return seg.query(0, N).mx;
        }

        Pair largestNonOverlap(ArrayList<Segment> arr) {
            Segment[] segs = new Segment[N + 1];
            int[] dp = new int[N + 1];
            for (int i = 0; i <= N; i++) {
                segs[i] = new Segment(-1, 0);
            }
            for (Segment s : arr) {
                if (s.li > segs[s.ri].li) {
                    segs[s.ri] = s;
                }
            }
            int[] used = new int[N + 1];
            for (int i = 1; i <= N; i++) {
                dp[i] = dp[i - 1];
                used[i] = used[i - 1];
                if (segs[i].li != -1) {
                    if (dp[i] < dp[segs[i].li - 1] + 1) {
                        used[i] = i;
                        dp[i] = dp[segs[i].li - 1] + 1;
                    }
                }
            }
            ArrayList<Segment> res = new ArrayList<>();
            int u = used[N];
            while (segs[u].li > 0) {
                res.add(segs[u]);
                u = used[segs[u].li - 1];
            }
            return new Pair(dp[N], res);
        }

        class Segment {
            int li;
            int ri;

            Segment() {
            }

            Segment(int li, int ri) {
                this.li = li;
                this.ri = ri;
            }

        }

        class Pair {
            int val;
            ArrayList<Segment> used = new ArrayList<>();

            Pair(int val, ArrayList<Segment> used) {
                this.val = val;
                this.used = used;
            }

        }

        static class SegmentTree {
            Node[] tree;
            int size = 0;

            public Node none() {
                //return a node that will do nothing while merging: ex. Infinity for min query, -Infinity for max query, 0 for sum
                Node res = new Node();
                return res;
            }

            public SegmentTree(int N) {
                tree = new Node[4 * N];
                size = N;
                for (int i = 0; i < 4 * N; i++) {
                    tree[i] = new Node();
                }
            }

            Node combine(Node a, Node b) {
                //change when doing different operations
                Node res = new Node();
                res.mx = Math.max(a.mx, b.mx);
                return res;
            }

            public Node query(int l, int r) {
                return queryUtil(1, 0, size - 1, l, r);
            }

            public Node queryUtil(int n, int tl, int tr, int l, int r) {
                //node number, cur range of node, cur range of query
                if (l > r) {
                    return none();
                }
                if (tl == l && tr == r) {
                    return tree[n];
                }
                int tm = (tl + tr) / 2;
                return combine(queryUtil(2 * n, tl, tm, l, Math.min(r, tm)), queryUtil(2 * n + 1, tm + 1, tr, Math.max(tm + 1, l), r));
            }

            public void add(int l, int r, int val) {
                //change query, not assignment
                addUtil(1, 0, size - 1, l, r, val);
            }

            public void addUtil(int n, int tl, int tr, int l, int r, int val) {
                if (l > r) {
                    return;
                }
                if (tl == l && tr == r) {
                    tree[n].update(val);
                } else {
                    int tm = (tl + tr) / 2;
                    addUtil(2 * n, tl, tm, l, Math.min(tm, r), val);
                    addUtil(2 * n + 1, tm + 1, tr, Math.max(l, tm + 1), r, val);
                    tree[n] = combine(tree[2 * n], tree[2 * n + 1]);
                }
            }

            class Node {
                int mx = 0;
                int lzy = 0;

                void update(int val) {
                    mx = Math.max(mx, val);
                    lzy += val;
                }

            }

        }

    }

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

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

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

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

    }
}


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

public class Main {

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

		int n=s.nextInt();

		long[] arr=new long[n];

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

		long[] pre=new long[n];

		pre[0]=arr[0];

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

		HashMap<Long,ArrayList<pair>> map=new HashMap<>();

		for(int i=0;i<n;i++)
		{
			for(int j=i;j<n;j++)
			{
				long key=pre[j]-pre[i]+arr[i];

				if(map.containsKey(key))
				{
					pair p=new pair(i+1,j+1);
					ArrayList<pair> temp=map.get(key);
					temp.add(p);

					map.put(key,temp);
				}
				else
				{
					ArrayList<pair> list=new ArrayList<>();
					pair p=new pair(i+1,j+1);
					list.add(p);

					map.put(key,list);
				}
			}
		}

		for(Map.Entry<Long,ArrayList<pair>> entry:map.entrySet())
		{
			ArrayList<pair> curr=entry.getValue();

			Collections.sort(curr,new comp());
		}

		long ans=0;
		long max=-1000000000000l;

		for(Map.Entry<Long,ArrayList<pair>> entry:map.entrySet())
		{
			ArrayList<pair> curr=entry.getValue();

			int count=1;
			int l=curr.get(0).l;
			int r=curr.get(0).r;

			for(int i=1;i<curr.size();i++)
			{
				if(curr.get(i).l>r)
				{
					count++;
					l=curr.get(i).l;
					r=curr.get(i).r;
				}
			}

			if(count>max)
			{
				max=count;
				ans=entry.getKey();
			}

		}

		System.out.println(max);

		ArrayList<pair> list=map.get(ans);

		System.out.println(list.get(0).l+" "+list.get(0).r);

		int l=list.get(0).l;
		int r=list.get(0).r;

		for(int i=1;i<list.size();i++)
		{
			if(list.get(i).l>r)
			{
				System.out.println(list.get(i).l+" "+list.get(i).r);
				l=list.get(i).l;
				r=list.get(i).r;
			}
		}

	}

}

class pair
{
	int l;
	int r;

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

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


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

import static java.lang.Math.*;

/* spar5h */

public class cf1 implements Runnable {

	static void addMap(int curr, HashMap<Integer, Integer> map, HashMap<Integer, Integer>[] hm, int j) {

		int prev = 0;

		if(map.get(curr) != null)
			prev = map.get(curr);

		int val = 0;

		if(hm[j].get(curr) != null)
			val = hm[j].get(curr);

		if(prev + 1 <= val)
			return;

		hm[j].put(curr, prev + 1);
	}

	public void run() {

		InputReader s = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);

		int n = s.nextInt();

		int[] a = new int[n];

		HashMap<Integer, Integer>[] hm = new HashMap[n];

		for(int i = 0; i < n; i++) {
			a[i] = s.nextInt();
			hm[i] = new HashMap<Integer, Integer>();
		}

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

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

			int curr = 0;

			for(int j = i; j < n; j++) {
				curr += a[j];
				addMap(curr, map, hm, j);
			}

			for(Map.Entry<Integer, Integer> e : hm[i].entrySet()) {

				if(map.get(e.getKey()) != null && map.get(e.getKey()) >= e.getValue())
					continue;

				map.put(e.getKey(), e.getValue());
			}
		}

		int key = -1;
		int value = 0;

		for(Map.Entry<Integer, Integer> e : map.entrySet()) {

			if(e.getValue() > value) {
				key = e.getKey(); value = e.getValue();
			}
		}

		w.println(value);

		int prev = -1;

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

			int curr = 0;

			for(int j = i; j > prev; j--) {

				curr += a[j];

				if(curr == key) {
					w.println((j + 1) + " " + (i + 1));
					prev = i;
					break;
				}
			}
		}

		w.close();
	}

	static class InputReader {

		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private 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 String nextLine() {

			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			String str = "";

			try {
	            str = br.readLine();
	        }
	        catch (IOException e) {
	            e.printStackTrace();
	        }

	        return str;
		}

		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 double nextDouble() {

			int c = read();

			while (isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-') {
				sgn = -1;
				c = read();
			}

			double res = 0;

			while (!isSpaceChar(c) && c != '.') {

				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());

				if (c < '0' || c > '9')
					throw new InputMismatchException();

				res *= 10;
				res += c - '0';
				c = read();
			}

			if (c == '.') {

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

			return res * sgn;
		}

		public String readString() {

			int c = read();

			while (isSpaceChar(c))
				c = read();

			StringBuilder res = new StringBuilder();

			do {
				res.appendCodePoint(c);
				c = read();
			}
			while (!isSpaceChar(c));

			return res.toString();
		}

		public boolean isSpaceChar(int c) {

			if (filter != null)
				return filter.isSpaceChar(c);

			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

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

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

	}

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


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.TreeMap;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.Map.Entry;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
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;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        F solver = new F();
        solver.solve(1, in, out);
        out.close();
    }

    static class F {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.ni();
            int[] a = in.na(n);
            TreeMap<Integer, TreeMap<Integer, Segment>> map = new TreeMap<>();
            int[] pref = new int[n + 1];
            for (int i = 0; i < n; i++) {
                pref[i + 1] = pref[i] + a[i];
            }

            for (int i = 0; i < n; i++) {
                for (int j = i; j >= 0; j--) {
                    int val = pref[i + 1] - pref[j];
                    TreeMap<Integer, Segment> dp = map.computeIfAbsent(val, k -> new TreeMap<>());
                    if (!dp.containsKey(i)) {

                        Map.Entry<Integer, Segment> lastEntry = dp.lastEntry();
                        if (lastEntry == null) {
                            dp.put(i, new Segment(j, i, 1, null));
                        } else {
                            Segment lastValue = lastEntry.getValue();
                            Map.Entry<Integer, Segment> prev = dp.lowerEntry(j);
                            if (prev == null) {
                                if (lastValue.dp >= 1)
                                    dp.put(i, lastValue);
                                else
                                    dp.put(i, new Segment(j, i, 1, null));
                            } else if (lastValue.dp >= prev.getValue().dp + 1) {
                                dp.put(i, lastValue);
                            } else {
                                dp.put(i, new Segment(j, i, prev.getValue().dp + 1, prev.getValue()));
                            }
                        }
                    }
                }
            }
            Segment best = null;
            for (TreeMap<Integer, Segment> segments : map.values()) {
                Segment seg = segments.lastEntry().getValue();
                if (best == null || best.dp < seg.dp) {
                    best = seg;
                }
            }
            if (best == null)
                throw new RuntimeException("Null best");
            out.println(best.dp);
            while (best != null) {
                out.printf("%d %d%n", best.from + 1, best.to + 1);
                best = best.prev;
            }
        }

        class Segment {
            int from;
            int to;
            int dp;
            Segment prev;

            public Segment(int from, int to, int dp, Segment prev) {
                this.from = from;
                this.to = to;
                this.dp = dp;
                this.prev = prev;
            }

        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int ni() {
            return Integer.parseInt(ns());
        }

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

    }
}


import java.util.*;

public class Main {
    static class Node implements Comparable<Node>{
        public int l,r;
        public long s;
        Node(int l,int r,long s){
            this.l=l;
            this.r=r;
            this.s=s;
        }
        public int compareTo(Node o) {
            if(o.s==s){
                if(r>o.r) return 1;
                else if(r==o.r) {
                    return 0;
                }
                else return -1;
            } else if(s>o.s){
                return 1;
            } else {
                return -1;
            }
        }
    }
    static long[] sum=new long[1550];
    public static void main(String[] args) {
        TreeMap<Long, ArrayList<Node> > mp = new TreeMap<>();
        Scanner cin = new Scanner(System.in);
        int N=cin.nextInt();
        for(int i=1;i<=N;i++){
            int x=cin.nextInt();
            sum[i]=sum[i-1]+x;
        }
        //System.out.println("here");
        ArrayList<Node> arr = new ArrayList<>();
        for(int l=1;l<=N;l++){
            for(int r=l;r<=N;r++){
                arr.add(new Node(l,r,sum[r]-sum[l-1]));
            }
        }
        Collections.sort(arr);
        for(int i=0;i<arr.size();i++){
            ArrayList<Node> a=mp.get(arr.get(i).s);
            if(a==null) {
                a=new ArrayList<>();
                mp.put(arr.get(i).s,a);
            }
            a.add(arr.get(i));
        }
        int mx=-1;
        long mxv=-1;
        Iterator<Long> it=mp.keySet().iterator();
        while(it.hasNext()){
            int ans=0,t=0;
            long v=it.next();
            ArrayList<Node> vec= mp.get(v);
            for(int i=0;i<vec.size();i++){
                if(t<vec.get(i).l){
                    ans++;
                    t=vec.get(i).r;
                }
            }
           //
            if(ans>mx){
                mx=ans;
                mxv=v;
               // System.out.println(mxv);
            }
        }
        ArrayList<Node> vec=mp.get(mxv);
        System.out.println(mx);
        int t=0;
        for(int i=0;i<vec.size();i++){

           // System.out.println(vec.get(i).l+" "+vec.get(i).r);
          // System.out.println("h");
            if(t<vec.get(i).l){
                System.out.println(vec.get(i).l+" "+vec.get(i).r);
                t=vec.get(i).r;
            }
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.HashMap;
import java.util.ArrayList;

/**
 * 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;
        Scanner in = new Scanner(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, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }

            Map<Long, List<Pair>> map = new HashMap<>();
            for (int r = 0; r < n; r++) {
                long sum = 0;
                for (int l = r; l >= 0; l--) {
                    sum += arr[l];
                    if (map.containsKey(sum)) {
                        map.get(sum).add(new Pair(l, r));
                    } else {
                        map.put(sum, new ArrayList<>());
                        map.get(sum).add(new Pair(l, r));
                    }
                }
            }
            int ans = -1;
            List<Pair> ansPairs = new ArrayList<>();
            for (long sum : map.keySet()) {
                List<Pair> pairs = map.get(sum);
                int count = 0;
                int idx = -1;
                List<Pair> tempPairs = new ArrayList<>();
                for (Pair pair : pairs) {
                    if (pair.i > idx) {
                        idx = pair.j;
                        tempPairs.add(pair);
                        count++;
                    }
                }
                if (ans < count) {
                    ans = count;
                    ansPairs = tempPairs;
                }
            }
            out.println(ans);
            for (Pair pair : ansPairs) {
                out.print((pair.i + 1) + " " + (pair.j + 1));
                out.println();
            }
        }

        class Pair {
            int i;
            int j;

            Pair(int p, int q) {
                i = p;
                j = q;
            }

        }

    }
}


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

public class b {

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

		int n=s.nextInt();
		long[] arr=new long[n];

		for(int i=0;i<n;i++) {
			arr[i]=s.nextLong();
		}
		HashMap<Long,ArrayList<pair>> map=new HashMap<>();

		ArrayList<pair> list=new ArrayList<>();
		for(int i=0;i<n;i++) {
			long sum=0;
			for(int j=i;j<n;j++) {
				sum=sum+arr[j];
				pair ob=new pair(i,j);
				if(map.containsKey(sum))
				{
					ArrayList p=map.get(sum);
					p.add(ob);
					map.put(sum, p);

				}else {
					ArrayList<pair> listt=new ArrayList<>();
					listt.add(ob);
					map.put(sum,listt);
				}
			}
		}

		long in=-1;
		int max=0;

		for(Map.Entry<Long, ArrayList<pair>> entry:map.entrySet()) {
			int l=1;
			ArrayList<pair> p=entry.getValue();
			Collections.sort(p,new comp());
			int now=p.get(0).end;
			for(int j=0;j<p.size();j++) {

				if(p.get(j).st>now) {
					l++;
					now=p.get(j).end;

				}

			}

			if(l>max) {
				max=l;
				in=entry.getKey();
			}
		}

		System.out.println(max);

		ArrayList<pair> d=map.get(in);
		int now=-1;
		for(int j=0;j<d.size();j++) {

			if(d.get(j).st>now) {
				System.out.println((d.get(j).st+1)+" "+(d.get(j).end+1));
				now=d.get(j).end;
				}

		}

	}
}
class pair{
	//long val;
	int st;
	int end;
	public pair(int st,int end) {
		//this.val=val;
		this.st=st;
		this.end=end;
	}
}
class comp implements Comparator<pair>{

	public int compare(pair h,pair j) {

		if(h.end<j.end) {
			return -1;
		}else if(h.end==j.end) {
			if(h.st<j.st) {
				return 1;
			}else if(h.st==j.st) {
				return 0;
			}else {
				return -1;
			}
		}else {
			return 1;
		}
	}
}


import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Solution {
    static final int INF = (int) 1e9;
    static final int mod = (int) (1e9 + 7);
    static final short UNCALC = -1;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        int[] a = sc.nextIntArray(n);
        long[] cum = new long[n];
        cum[0] = a[0];
        for (int i = 1; i < n; i++)
            cum[i] = a[i] + cum[i - 1];
        HashMap<Long, ArrayList<Pair>> hm = new HashMap<>();
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                long cur = get(cum, i, j);
                if (!hm.containsKey(cur)) hm.put(cur, new ArrayList<>());
                hm.get(cur).add(new Pair(i, j));
            }
        }
        int max = 0;
        StringBuilder ans = new StringBuilder();
        for (long sum : hm.keySet()) {
            ArrayList<Pair> cur = hm.get(sum);
            Collections.sort(cur);
            int poss = 0;
            int r = -1;
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < cur.size(); i++) {
                if (cur.get(i).left > r) {
                    poss++;
                    r = cur.get(i).right;
                    sb.append(cur.get(i));
                }
            }
            if (poss> max){
                max = poss;
                ans = sb;
            }
        }
        out.println(max);
        out.println(ans);
        out.flush();
        out.close();
    }

    static long get(long[] a, int i, int j) {
        return a[j] - (i > 0 ? a[i - 1] : 0);
    }

    static class Pair implements Comparable<Pair> {
        int left, right;

        public Pair(int left, int right) {
            this.left = left;
            this.right = right;
        }

        @Override
        public int compareTo(Pair o) {
            return right - o.right;
        }

        @Override
        public String toString() {
            return (left + 1) + " " + (right + 1) + "\n";
        }
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        public Scanner(String file) throws Exception {
            br = new BufferedReader(new FileReader(file));
        }

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

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

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

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

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

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

        public boolean ready() throws IOException {
            return br.ready();
        }

        public void waitForInput() throws InterruptedException {
            Thread.sleep(3000);
        }

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

        public Integer[] nextIntegerArray(int n) throws IOException {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public double[] nextDoubleArray(int n) throws IOException {
            double[] ans = new double[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextDouble();
            return ans;
        }

        public short nextShort() throws IOException {
            return Short.parseShort(next());
        }

    }
}


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

public class SameSumBlock {
	static BufferedReader br;
	static StringTokenizer tokenizer;

	public static void main(String[] args) throws Exception {
		br = new BufferedReader(new InputStreamReader(System.in));
		int n = nextInt();
		int[] arr = new int[n];
		int[] pSum = new int[n];
		for(int i = 0; i< n; i++) {
			arr[i] = nextInt();
			if(i != 0)
				pSum[i] += pSum[i - 1];
			pSum[i] += arr[i];
		}
		ArrayList<Interval> sorted = new ArrayList<Interval>();
		for(int i = 0; i < n; i++)
			sorted.add(new Interval(pSum[i],0, i));
		for(int i = 1; i < n; i++) {
			for(int j = i; j < n; j++) {
				sorted.add(new Interval(pSum[j] - pSum[i - 1], i, j));
			}
		}
		sorted.sort(null);
		int i = 0;
		int max = 0, idx = 0, end = 0;
		while(i < sorted.size()) {
			int last = i;
			int curr = 1;
			int start = i;
			sorted.get(i).marked = true;
			while(i < sorted.size() - 1 && sorted.get(i).val == sorted.get(i + 1).val) {
				i++;
				if(sorted.get(i).l > sorted.get(last).r) {
					sorted.get(i).marked = true;
					curr++;
					last = i;
				}
			}
			if(curr > max) {
				max = curr;
				idx = start;
				end = i;
			}
			i++;
		}
		System.out.println(max);
		for(int j = idx; j <= end; j++) {
			if(sorted.get(j).marked)
				System.out.println(sorted.get(j).l + 1 + " " + (sorted.get(j).r + 1));
		}
	}

	public static String next() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			String line = br.readLine();
			if (line == null)
				throw new IOException();
			tokenizer = new StringTokenizer(line);
		}
		return tokenizer.nextToken();
	}

	public static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
}
class Interval implements Comparable<Interval> {
	int val, l, r;
	boolean marked;
	public Interval(int val, int l, int r) {
		super();
		this.val = val;
		this.l = l;
		this.r = r;
	}

	@Override
	public int compareTo(Interval o) {
		if(val != o.val)
			return val - o.val;
		return r - o.r;
	}

}


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

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

      public Range(int a, int b)
      {
         l = a+1;
         r = b+1;
      }
   }