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();
        long s[] = new long[n+1];
        for(int i=0;i<n;++i){
            s[i+1] = s[i]  + ni();
        }

        Map<Long,List<int[]>> mp = new HashMap<>();
        for(int i=0;i<n;++i) {
            for (int j = i; j>=0; --j) {
                long 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;long vv = -1;
        for(long 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.util.*;
public class MyClass {
    static class Pair implements Comparable<Pair>{
        int x,y;
        Pair(int x,int y){
            this.x=x; this.y=y;
        }
        public int compareTo(Pair p){
            return Integer.compare(this.y,p.y);
        }
    }
    public static void main(String args[]) {
      Scanner in =new Scanner(System.in);
      HashMap<Long,ArrayList<Pair>> hm=new HashMap<Long,ArrayList<Pair>>();
      int n=in.nextInt();
      int a[]=new int[n];
      long sum[]=new long[n];
      long s=0;
      for(int i=0;i<n;i++){  a[i]=in.nextInt(); s+=a[i]; sum[i]=s; }
      for(int i=0;i<n;i++){
          for(int j=i;j<n;j++){
              long x=sum[j]-sum[i]+a[i];
              ArrayList<Pair> temp=new ArrayList<Pair>();
              if(hm.containsKey(x)) { temp=hm.get(x); }
              temp.add(new Pair(i+1,j+1));
              hm.put(x,temp);
          }
      }
      ArrayList<Pair> ans=new ArrayList<Pair>();
      for(Map.Entry em:hm.entrySet()){
          ArrayList<Pair> array=hm.get(em.getKey());
          Collections.sort(array);
          int prev=0;
          ArrayList<Pair> temp=new ArrayList<Pair>();
          for(int i=0;i<array.size();i++){
              if(array.get(i).x>prev){ temp.add(new Pair(array.get(i).x,array.get(i).y)); prev=array.get(i).y; }
          }
        //  System.out.println(temp.size());
          if(temp.size()>ans.size()){
              ans=(ArrayList<Pair>)temp.clone();
          }
      }
      long g=-5;
      System.out.println(ans.size());
      for(int i=0;i<ans.size();i++){
          System.out.println(ans.get(i).x+" "+ans.get(i).y);
      }
    }
}


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

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

  static class F1SameSumBlocksEasy {

    Map<Long, List<IntPair>> sums = new HashMap<>();

    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      long[] arr = in.nextLongArray(n);
      long[] pref = ArrayUtils.prefixSum(arr);
      for (int i = 0; i < n; ++i) {
        for (int j = i; j >= 0; --j) {
          long sum = pref[i + 1] - pref[j];
          if (sums.containsKey(sum)) {
            sums.get(sum).add(Factories.makeIntPair(j, i));
          } else {
            List<IntPair> pairs = new ArrayList<>();
            pairs.add(Factories.makeIntPair(j, i));
            sums.put(sum, pairs);
          }
        }
      }

      int best = 0;
      List<IntPair> res = new ArrayList<>();
      for (long sum : sums.keySet()) {
        List<IntPair> pairs = sums.get(sum);
        List<IntPair> temp = new ArrayList<>();
        int last = -1;
        for (IntPair cur : pairs) {
          if (cur.first > last) {
            last = cur.second;
            temp.add(cur);
          }
        }
        if (temp.size() > best) {
          best = temp.size();
          res = temp;
        }
      }
      out.println(best);
      for (IntPair pair : res) {
        out.println((pair.first + 1) + " " + (pair.second + 1));
      }
    }

  }

  static class ArrayUtils {

    public static long[] prefixSum(long[] arr) {
      long[] acc = new long[arr.length + 1];
      for (int i = 1; i <= arr.length; ++i) {
        acc[i] = acc[i - 1] + arr[i - 1];
      }
      return acc;
    }

  }

  static interface FastIO {

  }

  static final class Factories {

    private Factories() {
    }

    public static IntPair makeIntPair(int first, int second) {
      return new IntPair(first, second);
    }

  }

  static class IntPair implements Comparable<IntPair> {

    public int first;
    public int second;

    public IntPair() {
      first = second = 0;
    }

    public IntPair(int first, int second) {
      this.first = first;
      this.second = second;
    }

    public int compareTo(IntPair a) {
      if (first == a.first) {
        return Integer.compare(second, a.second);
      }
      return Integer.compare(first, a.first);
    }

    public String toString() {
      return "<" + first + ", " + second + ">";
    }

    public boolean equals(Object o) {
      if (this == o) {
        return true;
      }
      if (o == null || getClass() != o.getClass()) {
        return false;
      }

      IntPair a = (IntPair) o;

      if (first != a.first) {
        return false;
      }
      return second == a.second;
    }

    public int hashCode() {
      int result = first;
      result = 31 * result + second;
      return result;
    }

  }

  static class InputReader implements FastIO {

    private InputStream stream;
    private static final int DEFAULT_BUFFER_SIZE = 1 << 16;
    private static final int EOF = -1;
    private byte[] buf = new byte[DEFAULT_BUFFER_SIZE];
    private int curChar;
    private int numChars;

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

    public int read() {
      if (this.numChars == EOF) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return EOF;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public int nextInt() {
      int c;
      for (c = this.read(); isSpaceChar(c); c = this.read()) {
      }

      byte sgn = 1;
      if (c == 45) {
        sgn = -1;
        c = this.read();
      }

      int res = 0;

      while (c >= 48 && c <= 57) {
        res *= 10;
        res += c - 48;
        c = this.read();
        if (isSpaceChar(c)) {
          return res * sgn;
        }
      }

      throw new InputMismatchException();
    }

    public long nextLong() {
      int c;
      for (c = this.read(); isSpaceChar(c); c = this.read()) {
      }

      byte sgn = 1;
      if (c == 45) {
        sgn = -1;
        c = this.read();
      }

      long res = 0;

      while (c >= 48 && c <= 57) {
        res *= 10L;
        res += c - 48;
        c = this.read();
        if (isSpaceChar(c)) {
          return res * sgn;
        }
      }
      throw new InputMismatchException();
    }

    public static boolean isSpaceChar(int c) {
      return c == 32 || c == 10 || c == 13 || c == 9 || c == EOF;
    }

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

  }
}


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

public class B{

	static long []sum;

	static int n;

	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner();
		PrintWriter out=new PrintWriter(System.out);
		n=sc.nextInt();
		sum=new long [n+1];
		for(int i=1;i<=n;i++)
			sum[i]=sc.nextInt()+sum[i-1];
		HashMap<Long,Integer> map=new HashMap();
		ArrayList<int []>[]adj=new ArrayList[n*n+10];
		for(int i=0;i<adj.length;i++)
			adj[i]=new ArrayList();
		for(int r=1;r<=n;r++)
			for(int l=1;l<=n;l++) {
				if(r<l)
					continue;
				long x=sum[r]-sum[l-1];
				map.put(x, map.getOrDefault(x, map.size()));
				adj[map.get(x)].add(new int [] {l,r});
			}
		int ans=0;
		int bestIdx=0;
		for(int idx=0;idx<adj.length;idx++)
		{
			ArrayList<int[]>list=adj[idx];
			if(list.isEmpty())
				continue;
			int curr=1;
			int R=list.get(0)[1];
			for(int i=1;i<list.size();i++)
			{
				int []tmp=list.get(i);
				if(tmp[0]>R)
				{
					R=tmp[1];
					curr++;
				}
			}
			if(curr>=ans) {
				ans=curr;
				bestIdx=idx;
			}
		}
		out.println(ans);
		ArrayList<int[]>list=adj[bestIdx];
		int R=list.get(0)[1];
		out.println(list.get(0)[0]+" "+R);
		for(int i=1;i<list.size();i++)
		{
			int []tmp=list.get(i);
			if(tmp[0]>R)
			{
				R=tmp[1];
				out.println(tmp[0]+" "+tmp[1]);
			}
		}
		out.close();

	}

	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		Scanner(String fileName) throws FileNotFoundException{
			br=new BufferedReader(new FileReader(fileName));
		}
		String next() throws IOException {
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		String nextLine() throws IOException {
			return br.readLine();
		}
		int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		long nextLong()  throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}


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

public class Main
{
    static final long mod=(int)1e9+7;
    public static void main(String[] args) throws Exception
    {
    	FastReader in=new FastReader();
    	PrintWriter pw=new PrintWriter(System.out);
    	int n=in.nextInt();
    	int[] arr=new int[n+1];
    	for(int i=1;i<=n;i++)
    		arr[i]=in.nextInt();
    	Map<Integer,TreeMap<Integer,Integer>> map=new HashMap();
    	for(int i=1;i<=n;i++)
    	{
    		int sum=0;
    		for(int j=i;j<=n;j++)
    		{
    			sum+=arr[j];
    			if(map.containsKey(sum))
    			{
    				TreeMap<Integer,Integer> t=map.get(sum);
    				// System.out.println(t+" "+sum);
    				Map.Entry<Integer,Integer> e=t.lastEntry();
    				if(e.getKey()>j)
    				{
    					t.remove(e.getKey());
    					t.put(j,i);
    					map.put(sum,t);
    				}
    				else if(e.getKey()<i)
    				{
    					t.put(j,i);
    					map.put(sum,t);
    				}
    			}
    			else
    			{
    				TreeMap<Integer,Integer> t=new TreeMap();
    				t.put(j,i);
    				map.put(sum,t);
    			}
    		}
    	}
    	int ans=0,size=0;
    	for(Map.Entry<Integer,TreeMap<Integer,Integer>> e:map.entrySet())
    	{
    		if(e.getValue().size()>size)
    		{
    			ans=e.getKey();
    			size=e.getValue().size();
    		}
    	}
    	pw.println(size);
    	for(Map.Entry e:map.get(ans).entrySet())
    		pw.println(e.getValue()+" "+e.getKey());
    	pw.flush();
    }
}

class pair
{
	int f,s;
}

class FastReader
{
    BufferedReader br;
    StringTokenizer st;

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

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

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

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


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

public class Codeforces{

	static class MyScanner{
		BufferedReader br;
		StringTokenizer st;

		MyScanner(FileReader fileReader){
			br = new BufferedReader(fileReader);
		}

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

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

		char nc(){
			return nn().charAt(0);
		}

		int ni(){
			return Integer.parseInt(nn());
		}

		long nl(){
			return Long.parseLong(nn());
		}

		double nd(){
			return Double.parseDouble(nn());
		}

		int[] niArr0(int n){
			int[] ar = new int[n];
			for(int i = 0; i < n; i++) ar[i] = ni();
			return ar;
		}

		int[] niArr1(int n){
			int[] ar = new int[n + 1];
			for(int i = 1; i <= n; i++) ar[i] = ni();
			return ar;
		}

		long[] nlArr0(int n){
			long[] ar = new long[n];
			for(int i = 0; i < n; i++) ar[i] = nl();
			return ar;
		}
	}

	public static <T> void mprintln(T ... ar){
		for(T i: ar) out.print(i + " ");
		out.println();
	}

	private static PrintWriter out;

	public static void main(String[] args) throws FileNotFoundException{

		// Input from file
		// File inputFile = new File("JavaFile.txt");
		// File outputFile = new File("JavaOutputFile.txt");
		// FileReader fileReader = new FileReader(inputFile);
		// Here it ends

		MyScanner sc = new MyScanner();
		// MyScanner sc = new MyScanner(fileReader);

		out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
		// out = new PrintWriter(new PrintStream(outputFile)); // Output to file

		getAns(sc);

		out.close();
	}

	private static void getAns(MyScanner sc){
		int n = sc.ni();
		long[] ar = sc.nlArr0(n);

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

		for(int i = 0; i < n; i++){
			long cur = 0;
			for(int j = i; j >= 0; j--){
				cur += ar[j];
				if(!map.containsKey(cur)) map.put(cur, new ArrayList());
				map.get(cur).add(new int[]{j + 1, i + 1});
			}
		}

		// System.out.println(map);

		Set<Long> set = map.keySet();
		// System.out.println(set);
		ArrayList<int[]> ans = new ArrayList();

		for(Long l: set){
			ArrayList<int[]> cur = new ArrayList();
			int right = -1;
			for(int[] arc: map.get(l)) if(arc[0] > right){
				right = arc[1];
				cur.add(arc);
			}

			if(cur.size() > ans.size()) ans = cur;
		}

		out.println(ans.size());
		for(int[] arc: ans) mprintln(arc[0], arc[1]);
	}
}


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


import java.util.HashMap;
import java.util.Scanner;

public class Main{

	int[] ints;
	int[] prefix;

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

	public void run()
	{
		Scanner file = new Scanner(System.in);
		int N = file.nextInt();
		ints = new int[N];
		for(int i = 0;i<N;i++)
			ints[i] = file.nextInt();
		prefix = new int[N];
		prefix[0] = ints[0];
		for(int i =1;i<prefix.length;i++)
			prefix[i] = prefix[i-1]+ints[i];
		HashMap<Integer,Integer> ending = new HashMap<>();//ending for each sum
		HashMap<Integer,Integer> amount = new HashMap<>();//k for each sum
		for(int end = 0;end<prefix.length;end++)
		{
			for(int start = 0;start<=end;start++)
			{
				int sum = sum(start,end);
				if(!ending.containsKey(sum))
					ending.put(sum, -1);
				if(!amount.containsKey(sum))
					amount.put(sum,0);
				if(ending.get(sum)<start)
				{
					amount.put(sum,amount.get(sum)+1);
					ending.put(sum,end);
				}
			}
		}
		int max = 0;
		int maxnum = -1;
		for(int x:amount.keySet())
		{
			if(amount.get(x)>max)
			{
				max = amount.get(x);
				maxnum = x;
			}
		}
		System.out.println(max);
		HashMap<Integer,Integer> occurrence = new HashMap<Integer,Integer>();
		occurrence.put(0,0);
		for(int i = 0;i<prefix.length;i++)
		{
			if(occurrence.containsKey(prefix[i]-maxnum))
			{
				System.out.println(occurrence.get(prefix[i]-maxnum)+1+" "+(i+1));
				occurrence.clear();
			}
			occurrence.put(prefix[i],i+1);
		}
	}

	public int sum(int L, int R)
	{
		return prefix[R] - prefix[L] + ints[L];
	}

}


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

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

        int N = sc.nextInt();
        int[] pre = new int[N + 1];
        var ansMap = new HashMap<Integer, ArrayDeque<Pair>>();
        for (int j = 1; j <= N; j++) {
            pre[j] = pre[j - 1] + sc.nextInt();
            for (int i = j; i >= 1; i--) {
                int sum = pre[j] - pre[i - 1];
                /**
                 we can actually perform the greedy scheduling as we read in the information!
                 Because we are sweeping with an increasing right pointer, the moment a sum is
                 found with this right endpoint, we can greedily place it into the schedule
                 for a given sum "bucket", (if it's disjoint. Otherwise, we would be replacing
                 one OR MORE previous intervals, which would only decrease or keep the same size,
                 while reducing our future accessibility for adding intervals!)
                 */
                if (!ansMap.containsKey(sum) || ansMap.get(sum).getLast().r < i) {
                    var dq = ansMap.computeIfAbsent(sum, val -> new ArrayDeque<>());
                    dq.add(new Pair(i, j, sum));
                }
            }
        }
        var ans = new ArrayDeque<Pair>();
        for (var group : ansMap.values()) {
            if (group.size() > ans.size()) {
                ans = group;
            }
        }
        out.println(ans.size());
        for (Pair p : ans) {
            out.println(p);
        }
        out.close();
    }

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

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

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

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

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

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

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

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

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

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

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

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

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


import java.util.*;

public class F2 {

    private static int n;
    private static int[] a;

    private static Collection<Segment> answer;

    public static void main(String[] args) {
        in();
        solution();
        out();
    }

    private static void in() {

        Scanner in = new Scanner(System.in);

        n = in.nextInt();

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

    }

    private static void solution() {

        HashMap<Long, LinkedList<Segment>> segments = new HashMap<>();

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

            long sum = 0;

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

                sum += a[j];

                if (segments.containsKey(sum)) {
                    segments.get(sum).add(new Segment(i, j));
                } else {
                    LinkedList<Segment> toPut = new LinkedList<>();
                    toPut.add(new Segment(i, j));
                    segments.put(sum, toPut);
                }

            }

        }

        answer = null;
        for (Map.Entry<Long, LinkedList<Segment>> sums : segments.entrySet()) {

            LinkedList<Segment> currentSegments = sums.getValue();
            Collections.sort(currentSegments);

            LinkedList<Segment> segmentsWithoutCrossing = new LinkedList<>();

            for (Segment segment : currentSegments) {

                if ( segmentsWithoutCrossing.isEmpty() || !segmentsWithoutCrossing.getLast().isCrossingToNextSegment(segment)) {

                    segmentsWithoutCrossing.add(segment);

                } else if (segmentsWithoutCrossing.getLast().getR() > segment.getR()) {

                    segmentsWithoutCrossing.removeLast();
                    segmentsWithoutCrossing.add(segment);

                }

            }

            answer = segmentsWithoutCrossing.size() > (answer != null ? answer.size() : 0) ? segmentsWithoutCrossing : answer;

        }

    }

    private static void out() {

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

        for (Segment segment : answer) {
            System.out.println( (segment.getL() + 1) + " " + (segment.getR() + 1));
        }

    }

}

class Segment implements Comparable<Segment>{

    private int l, r;

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

    int getL() {
        return l;
    }

    int getR() {
        return r;
    }

    @Override
    public int compareTo(Segment segment) {

        if (l == segment.l && r == segment.r) {
            return 0;
        }

        return l != segment.l ? l - segment.l : r - segment.r;

    }

    boolean isCrossingToNextSegment(Segment segment) {
        if (l == segment.l || r == segment.r) {
            return true;
        } else if (l < segment.l) {
            return r >= segment.l;
        } else if (r > segment.r) {
            return l <= segment.r;
        } else {
            return true;
        }
    }

}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class F1141 {

	private static class Interval {
		public int l;
		public int r;

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

	public static void main(String[] args) throws IOException {
//		BufferedReader br = new BufferedReader(new FileReader("F:/books/input.txt"));
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		int n = Integer.parseInt(s);
		long[] a = new long[n];
		String[] as = br.readLine().split(" ");
		for(int i=0;i<n;i++) {
			a[i] = Long.parseLong(as[i]);
		}
		StringBuffer sb = solve(a,n);
		System.out.println(sb.toString());
	}

	private static StringBuffer solve(long[] a, int n) {
		StringBuffer ret = new StringBuffer("");
		Map<Long,List<Interval>> mp = new HashMap<Long,List<Interval>>();
		long max = 0,maxId = -1;
		for(int i=n-1;i>=0;i--) {
			long s=0;
			long prev = 1;
			for(int j=i;j<n;j++) {
				s+=a[j];
//				System.out.println(i+","+j);
				Interval inter = new Interval(i,j);
//				if(prev==1 || prev==-1) {
					List<Interval> ints = mp.get(s);
					if(ints==null) ints = new ArrayList<Interval>();
					if(ints.size()==0 || ints.get(0).l>j) {
						ints.add(0,inter);
					}
					if(ints.size()>max) {
						max = ints.size();
						maxId = s;
					}
					mp.put(s, ints);
//				}
				if(j<n-1) prev =  a[j+1]-a[j];
			}
		}
		List<Interval> l = mp.get(maxId);
		ret.append(l.size()+ "\n");
		for(Interval inter : l) {
			ret.append((inter.l+1) + " " + (inter.r+1) + "\n");
		}
		return ret;
	}

}


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+1,i+1});
            }
        }
        int all = 0;int vv = -1;
        for(int v:mp.keySet()){
            List<int[]> r = mp.get(v);
            ;int c = 0;
            int ri = -2000000000;
            for(int [] fk : r){
                if(fk[0]>ri){
                    ri = fk[1];c++;
                }
            }
            if(c>all){
                all = c;
                vv = v;
            }
        }
        println(all);
        List<int[]> r = mp.get(vv);
        int ri = -2000000000;
        for(int fk[]:r){
            if(fk[0]>ri){
                ri = fk[1];println((fk[0])+" "+(fk[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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

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

    static class F2SameSumBlocksHard {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();

            long[] a = in.nextLongArray(n);

            long[] p = in.calculatePrefixSum(a);

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

            for (int i = 0; i < n; i++) {
                long sum = 0;
                for (int j = i; j < n; j++) {
                    sum += a[j];
                    map.merge(sum, 1, (x, y) -> x + y);
                }
            }

            List<sum> sums = new ArrayList<>();
            for (long sum : map.keySet()) {
                sums.add(new sum(sum, map.get(sum)));
            }

            sums.sort((x, y) -> y.c - x.c);

            int ans = -1;

            int[] fca = null;
            long mxsum = -1;
            for (int i = 0; i < sums.size(); i++) {
                sum cs = sums.get(i);
                long sum = cs.sum;
                long c = cs.c;

                if (c < ans) {
                    continue;
                }

                Map<Long, Integer> lm = new HashMap<>();

                int[] ca = new int[n];
                lm.put(0l, -1);
                for (int j = 0; j < n; j++) {
                    long val = p[j];

                    if (j > 0) {
                        ca[j] = ca[j - 1];
                    }
                    long req = val - sum;

                    if (lm.containsKey(req)) {
                        int li = lm.get(req);
                        if (li == -1)
                            ca[j] = Math.max(1, ca[j]);
                        else
                            ca[j] = Math.max(1 + ca[li], ca[j]);
                    }

                    lm.put(val, j);
                }

                if (ca[n - 1] > ans) {
                    ans = ca[n - 1];
                    mxsum = sum;
                    fca = ca;
                }
            }

            List<Integer> al = new ArrayList<>();

            long sum = 0;
            for (int i = n - 1; i >= 0; i--) {
                if (i > 0 && fca[i] != fca[i - 1]) {
                    sum = 0;
                    al.add(i + 1);
                    do {
                        sum += a[i];
                        i--;
                    } while (i >= 0 && sum != mxsum);
                    i++;
                    al.add(i + 1);
                } else if (i == 0) {
                    if (a[i] == mxsum) {
                        al.add(i + 1);
                        al.add(i + 1);
                    }
                }
            }

            out.println(al.size() / 2);

            for (int i = al.size() - 1; i >= 0; i -= 2) {
                out.println(al.get(i) + " " + al.get(i - 1));
            }
        }

        class sum {
            long sum;
            int c;

            public sum(long sum, int c) {
                this.sum = sum;
                this.c = c;
            }

        }

    }

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

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

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

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

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

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

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

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

        public long[] calculatePrefixSum(long[] a) {
            int n = a.length;

            long[] prefixSum = new long[n];

            prefixSum[0] = a[0];

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

            return prefixSum;
        }

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

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

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

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

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

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

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

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

    }
}


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

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

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

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

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

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

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

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

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

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

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

            out.println(resS);
        }

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

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

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

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

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

        }

    }

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

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

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

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

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

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

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

    }
}


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

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

	FastReader in = new FastReader();
	PrintWriter out = new PrintWriter(System.out);
	void run(){
		work();
		out.flush();
	}
	long mod=998244353;
	long gcd(long a,long b) {
		return b==0?a:gcd(b,a%b);
	}
	void work() {
		int n=in.nextInt();
		int[] A=new int[n];
		for(int i=0;i<n;i++)A[i]=in.nextInt();
		HashMap<Integer,Integer> map=new HashMap<>();
		HashMap<Integer,ArrayList<int[]>> rec=new HashMap<>();
		for(int i=0;i<n;i++) {
			for(int j=i,cur=0;j>=0;j--) {
				cur+=A[j];
				if(map.get(cur)==null) {
					map.put(cur,i);
					rec.put(cur,new ArrayList<>());
					rec.get(cur).add(new int[] {j,i});
				}else if(map.get(cur)<j) {
					map.put(cur,i);
					rec.get(cur).add(new int[] {j,i});
				}
			}
		}
		ArrayList<int[]> ret=null;
		for(ArrayList<int[]> list:rec.values()) {
			if(ret==null||ret.size()<list.size()) {
				ret=list;
			}
		}
		out.println(ret.size());
		for(int[] r:ret) {
			out.println((r[0]+1)+" "+(r[1]+1));
		}
	}
}

class FastReader
{
	BufferedReader br;
	StringTokenizer st;

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

	public String next()
	{
		if(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());
	}

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


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

public class Solution {

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());

		long[] a = new long[n];

		for (int i = 0; i < a.length; i++) {
			a[i] = Long.parseLong(st.nextToken());
		}

		long[] sum = new long[n];
		sum[0] = a[0];
		for (int i = 1; i < sum.length; i++) {
			sum[i] = sum[i - 1] + a[i];
		}

		solve(a, sum);

	}

	private static void solve(long[] a, long[] sum) {
		int n = a.length;

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

		for (int j = 0; j < sum.length; j++) {
			for (int i = 0; i <= j; i++) {
				long k = getSum(sum, i, j);
				if (map.containsKey(k)) {
					map.get(k).add(new Pair(i, j));
				} else {
					List<Pair> arr = new ArrayList<>();
					arr.add(new Pair(i, j));
					map.put(k, arr);
				}
			}
		}

		int max = -1;
		List<Pair> ans = null;
		for (Map.Entry<Long, List<Pair>> entry : map.entrySet()) {
			List<Pair> pairs = entry.getValue();

			int prev = -1;
			int count = 0;
			List<Pair> temp = new ArrayList<Pair>();
			for (Pair p : pairs) {
				if (p.x > prev) {
					prev = p.y;
					temp.add(p);
					count++;
				}
			}

			if (count > max) {
				ans = temp;
				max = count;
			}
		}
		if (max != -1) {
			System.out.println(ans.size());
			for (Pair p : ans) {
				System.out.println((p.x + 1) + " " + (p.y + 1));
			}
		}
	}

	private static long getSum(long[] sum, int l, int r) {
		if (l == 0) {
			return sum[r];
		}
		return sum[r] - sum[l - 1];
	}
}

class Pair {

	int x;
	int y;

	Pair(int x, int y) {
		this.x = x;
		this.y = y;
	}

	@Override
	public int hashCode() {
		int h = 171 << 4;
		h = h * x;
		h = h * y;
		return h;
	}

	@Override
	public boolean equals(Object o) {
		if (o instanceof Pair) {
			Pair other = (Pair) o;
			return this.x == other.x && this.y == other.y;
		}
		return false;
	}

	@Override
	public String toString() {
		return "Pair [x=" + x + ", y=" + y + "]";
	}

}


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

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

        int N = sc.nextInt();
        int[] pre = new int[N + 1];
        for (int i = 1; i <= N; i++) {
            pre[i] = pre[i - 1] + sc.nextInt();
        }
//        var sumMap = new HashMap<Integer, ArrayList<Pair>>();
//        var sums = new ArrayList<Pair>();
        Pair[] sums = new Pair[N * (N + 1) / 2];
        int k = 0;
        for (int i = 1; i <= N; i++) {
            for (int j = i; j <= N; j++) {
                int sum = pre[j] - pre[i - 1];
//                sumMap.computeIfAbsent(sum, val -> new ArrayList<>()).add(new Pair(i, j, sum));
                sums[k++] = new Pair(i, j, sum);
            }
        }
        Arrays.sort(sums, (p1, p2) -> p1.sum - p2.sum != 0 ? p1.sum - p2.sum : p1.r - p2.r);
        var ans = new ArrayList<Pair>();
        int i = 0;
        while (i < k) {
            var group = new ArrayList<Pair>();
            int last = 0;
            int j = i;
            while (j < k && sums[j].sum == sums[i].sum) {
                if (sums[j].l > last) {
                    group.add(sums[j]);
                    last = sums[j].r;
                }
                j++;
            }
//            System.out.println(group);
            if (group.size() > ans.size()) {
                ans = group;
            }
            i = j;
        }
        out.println(ans.size());
        for (Pair p : ans) {
            out.println(p);
        }
        out.close();
    }

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

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

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

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

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

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

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

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

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

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

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

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

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


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

public class Task {

    public static void solve() throws Exception {
	int n = nextInt();
	int[] S = new int[n];
	for(int i=0;i<n;i++) {
	    S[i] = nextInt();
	    if(i > 0) {
		S[i] += S[i-1];
	    }
	}
	Map<Integer, List<L>> map = new HashMap<>();
	for(int j=0;j<n;j++) {
	    for(int i=j;i>=0;i--) {
		int sum = S[j];
		if(i > 0) {
		    sum -= S[i-1];
		}
		L l = new L();
		l.a = i;
		l.b = j;
		List<L> list = map.get(sum);
		if(list == null) {
		    list = new ArrayList<>();
		    map.put(sum, list);
		}
		list.add(l);
	    }
	}
	List<L> longest = null;
	for(Integer sum: map.keySet()) {
	    List<L> list = map.get(sum);
	    Collections.sort(list);
	    List<L> list2 = new ArrayList<>(list.size());
	    int from = list.get(0).a;
	    for(L l: list) {
		if(l.a >= from) {
		    list2.add(l);
		    from = l.b + 1;
		}
	    }
	    if(longest == null || longest.size() < list2.size()) {
		longest = list2;
	    }
	}

	println(longest.size());
	for(int i=0;i<longest.size();i++) {
	    L l = longest.get(i);
	    println((l.a+1) + " " + (l.b+1));
	}
    }

    private static class L implements Comparable<L>{
	int a;
	int b;

	@Override
	public int compareTo(L l2) {
	    return Integer.valueOf(b).compareTo(l2.b);
	}
    }

    public static void main(String[] args) throws Exception {
	try {
	    fastReader = new FastReader(System.in);
	    systemOut = new BufferedOutputStream(System.out);
	    solve();
	} finally {
	    systemOut.close();
	}
    }

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

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

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

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

    public static void println(String str) {
	try {
	    print(str);
	    systemOut.write('\n');
	} catch (Exception ex) {
	    throw new RuntimeException(ex);
	}
    }

    public static String next() {
	return fastReader.readNextToken(false);
    }

    public static String nextLine() {
	return fastReader.readNextToken(true);
    }

    public static int nextInt() {
	return Integer.parseInt(fastReader.readNextToken(false));
    }

    public static long nextLong() {
	return Long.parseLong(fastReader.readNextToken(false));
    }

    public static double nextDouble() {
	return Double.parseDouble(fastReader.readNextToken(false));
    }

    static class FastReader {
	private byte[] buf = new byte[65536];
	private int ind = 0;
	private int maxInd = -1;
	private InputStream is = null;
	private boolean eof = false;
	private boolean lastCharRead = false;

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

	public String readNextToken(boolean endOfLine) {
	    try {
		StringBuilder sb = new StringBuilder();
		boolean found = false;
		while (true) {
		    if (lastCharRead) {
			return null;
		    } else if (ind > maxInd) {
			if (eof) {
			    lastCharRead = true;
			} else {
			    fillBuffer();
			}
		    }
		    byte b = '\n';
		    if (!lastCharRead) {
			b = buf[ind++];
		    }

		    if (b == '\r') {
			// ignore
		    } else if ((b == '\n' && endOfLine) || (Character.isWhitespace(b) && !endOfLine)) {
			if (found) {
			    break;
			}
		    } else {
			sb.append((char) b);
			found = true;
		    }
		}
		return sb.toString();
	    } catch (Exception ex) {
		throw new RuntimeException(ex);
	    }
	}

	private void fillBuffer() {
	    try {
		int read = is.read(buf, 0, buf.length);
		if (read < buf.length) {
		    eof = true;
		}
		ind = 0;
		maxInd = read - 1;
	    } catch (Exception ex) {
		throw new RuntimeException(ex);
	    }
	}
    }

    public static class LST {
	public long[][] set;
	public int n;

	public LST(int n) {
	    this.n = n;
	    int d = 1;
	    for (int m = n; m > 1; m >>>= 6, d++)
		;

	    set = new long[d][];
	    for (int i = 0, m = n >>> 6; i < d; i++, m >>>= 6) {
		set[i] = new long[m + 1];
	    }
	}

	// [0,r)
	public LST setRange(int r) {
	    for (int i = 0; i < set.length; i++, r = r + 63 >>> 6) {
		for (int j = 0; j < r >>> 6; j++) {
		    set[i][j] = -1L;
		}
		if ((r & 63) != 0)
		    set[i][r >>> 6] |= (1L << r) - 1;
	    }
	    return this;
	}

	// [0,r)
	public LST unsetRange(int r) {
	    if (r >= 0) {
		for (int i = 0; i < set.length; i++, r = r + 63 >>> 6) {
		    for (int j = 0; j < r + 63 >>> 6; j++) {
			set[i][j] = 0;
		    }
		    if ((r & 63) != 0)
			set[i][r >>> 6] &= ~((1L << r) - 1);
		}
	    }
	    return this;
	}

	public LST set(int pos) {
	    if (pos >= 0 && pos < n) {
		for (int i = 0; i < set.length; i++, pos >>>= 6) {
		    set[i][pos >>> 6] |= 1L << pos;
		}
	    }
	    return this;
	}

	public LST unset(int pos) {
	    if (pos >= 0 && pos < n) {
		for (int i = 0; i < set.length && (i == 0 || set[i - 1][pos] == 0L); i++, pos >>>= 6) {
		    set[i][pos >>> 6] &= ~(1L << pos);
		}
	    }
	    return this;
	}

	public boolean get(int pos) {
	    return pos >= 0 && pos < n && set[0][pos >>> 6] << ~pos < 0;
	}

	public LST toggle(int pos) {
	    return get(pos) ? unset(pos) : set(pos);
	}

	public int prev(int pos) {
	    for (int i = 0; i < set.length && pos >= 0; i++, pos >>>= 6, pos--) {
		int pre = prev(set[i][pos >>> 6], pos & 63);
		if (pre != -1) {
		    pos = pos >>> 6 << 6 | pre;
		    while (i > 0)
			pos = pos << 6 | 63 - Long.numberOfLeadingZeros(set[--i][pos]);
		    return pos;
		}
	    }
	    return -1;
	}

	public int next(int pos) {
	    for (int i = 0; i < set.length && pos >>> 6 < set[i].length; i++, pos >>>= 6, pos++) {
		int nex = next(set[i][pos >>> 6], pos & 63);
		if (nex != -1) {
		    pos = pos >>> 6 << 6 | nex;
		    while (i > 0)
			pos = pos << 6 | Long.numberOfTrailingZeros(set[--i][pos]);
		    return pos;
		}
	    }
	    return -1;
	}

	private static int prev(long set, int n) {
	    long h = set << ~n;
	    if (h == 0L)
		return -1;
	    return -Long.numberOfLeadingZeros(h) + n;
	}

	private static int next(long set, int n) {
	    long h = set >>> n;
	    if (h == 0L)
		return -1;
	    return Long.numberOfTrailingZeros(h) + n;
	}

	@Override
	public String toString() {
	    List<Integer> list = new ArrayList<Integer>();
	    for (int pos = next(0); pos != -1; pos = next(pos + 1)) {
		list.add(pos);
	    }
	    return list.toString();
	}
    }
}


import java.util.*;

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

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

        int[] prefixSum = new int[n + 1];
        prefixSum[0] = 0;
        for (int i = 1; i <= n; i++) {
            prefixSum[i] = prefixSum[i - 1] + a[i];
        }

        Map<Integer, List<Segment>> sumToSegments = new HashMap<>();
        for (int i = 1; i <= n; i++) {
            for (int j = i; j <= n; j++) {
                int sum = prefixSum[j] - prefixSum[i - 1];
                sumToSegments
                        .computeIfAbsent(sum, $ -> new ArrayList<>())
                        .add(Segment.make(i, j));
            }
        }

        List<Segment> bestSegments = null;
        for (int sum : sumToSegments.keySet()) {
            List<Segment> segments = sumToSegments.get(sum);
            int size = segments.size();

            int[] f = new int[size];
            int[] next = new int[size];
            boolean[] take = new boolean[size];

            f[size - 1] = 1;
            next[size - 1] = -1;
            take[size - 1] = true;
            int bestStartIndex = size - 1;

            for (int i = size - 2; i >= 0; i--) {
                int nextIndex;

                if (segments.get(i).q >= segments.get(size - 1).p) {
                    nextIndex = -1;
                } else {
                    int L = i + 1;
                    int R = size - 1;
                    while (L < R) {
                        int M = (L + R) / 2;
                        if (segments.get(i).q >= segments.get(M).p) { /* intersection */
                            L = M + 1;
                        } else {
                            R = M;
                        }
                    }
                    nextIndex = L;
                }

                f[i] = 1 + ((nextIndex == -1) ? 0 : f[nextIndex]);
                next[i] = nextIndex;
                take[i] = true;

                if (f[i + 1] > f[i]) {
                    take[i] = false;
                    f[i] = f[i + 1];
                    next[i] = i + 1;
                }

                if (bestStartIndex == -1 || f[i] > f[bestStartIndex]) {
                    bestStartIndex = i;
                }
            }

            // recover segment set
            List<Segment> maxForSum = new ArrayList<>();
            int index = bestStartIndex;
            do {
                if (take[index]) {
                    maxForSum.add(segments.get(index));
                }
                index = next[index];
            } while (index != -1);

            if (bestSegments == null || maxForSum.size() > bestSegments.size()) {
                bestSegments = maxForSum;
            }
        }

        System.out.println(bestSegments.size());
        for (Segment segment : bestSegments) {
            System.out.printf("%s %s%n", segment.p, segment.q);
        }

        in.close();
    }

    private static class Segment {
        public final int p;
        public final int q;

        private Segment(int p, int q) {
            this.p = p;
            this.q = q;
        }

        public static Segment make(int p, int q) {
            return new Segment(p, q);
        }
    }
}