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

  static InputReader in = new InputReader(System.in);
  static PrintWriter out = new PrintWriter(System.out);

  public static void main(String[] args) {
    boolean even = true;
    int n = in.nextInt();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = in.nextInt();
      for (int j = 0; j < i; j++) {
        if (a[j] > a[i]) {
          even = !even;
        }
      }
    }
    int m = in.nextInt();
    for (int i = 0; i < m; i++) {
      if ((1 - in.nextInt() + in.nextInt()) / 2 % 2 == 1) {
        even = !even;
      }
      if (even)
        out.println("even");
      else
        out.println("odd");
    }
    finish();
  }

  public static void finish() {
    out.close();
    in.close();
    System.exit(0);
  }

  static class InputReader implements Iterator<String>, Closeable {
    // Fast input reader. Based on Kattio.java from open.kattis.com
    // but has method names to match Scanner

    private BufferedReader r;
    private String line;
    private StringTokenizer st;
    private String token;

    public InputReader(InputStream i) {
      r = new BufferedReader(new InputStreamReader(i));
    }

    public boolean hasNext() {
      return peekToken() != null;
    }

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

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

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

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

    public String nextLine() {
      try {
        line = r.readLine();
      } catch (IOException e) {
        line = null;
      }
      token = null;
      st = null;
      return line;
    }

    public void close() {
      try {
        r.close();
      } catch (IOException e) {
      }
    }

    private String peekToken() {
      if (token == null)
        try {
          while (st == null || !st.hasMoreTokens()) {
            line = r.readLine();
            if (line == null)
              return null;
            st = new StringTokenizer(line);
          }
          token = st.nextToken();
        } catch (IOException e) {
        }
      return token;
    }

    private String nextToken() {
      String ans = peekToken();
      token = null;
      return ans;
    }

  }

}


import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.util.Map.Entry;

public class Template {

    String fileName = "";
    long INF = Long.MAX_VALUE / 3;
    int MODULO = 1000*1000*1000+7;
    long[] fenwik;
    int BORDER = 1000*1000+100;
    void solve() throws IOException {
        int n = readInt();
        int[] a = new int[n];
        for(int i=0; i<n; ++i){
            a[i] = readInt();
        }
        fenwik = new long[BORDER];
        long ans = 0;
        for(int i=n-1;i>=0;--i){
            ans+=sumFenwik(a[i]);
            incFenwik(a[i],1);
        }
        boolean even = ans % 2 == 0;
        int m = readInt();
        for(int i=0; i<m; ++i){
            int l = readInt();
            int r = readInt();

            if(((r-l+1)/2)%2==1){
                even = !even;
            }

            out.println(even?"even":"odd");
        }
    }

    void incFenwik(int i, int delta){
        for(;i<BORDER;i = i|(i+1)){
            fenwik[i]+=delta;
        }
    }

    long sumFenwik(int r){
        long sum = 0;
        for(;r>=0;r = (r&(r+1))-1){
            sum+=fenwik[r];
        }
        return sum;
    }

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

    long binPow(long a, long b, long m) {
        if (b == 0) {
            return 1;
        }
        if (b % 2 == 1) {
            return ((a % m) * (binPow(a, b - 1, m) % m)) % m;
        } else {
            long c = binPow(a, b / 2, m);
            return (c * c) % m;
        }

    }
    class Fenwik {
        long[] t;
        int length;

        Fenwik(int[] a) {
            length = a.length + 100;
            t = new long[length];

            for (int i = 0; i < a.length; ++i) {
                inc(i, a[i]);
            }
        }

        void inc(int ind, int delta) {
            for (; ind < length; ind = ind | (ind + 1)) {
                t[ind] += delta;
            }
        }

        long getSum(int r) {
            long sum = 0;
            for (; r >= 0; r = (r & (r + 1)) - 1) {
                sum += t[r];
            }
            return sum;
        }
    }

    class SegmentTree {
        int[] t;

        SegmentTree(int[] a) {
            int n = a.length - 1;
            t = new int[n * 4];
            build(a, 1, 1, n);
        }

        void build(int[] a, int v, int tl, int tr) {
            if (tl == tr) {
                t[v] = a[tl];
                return;
            }

            int mid = (tr + tl) / 2;

            build(a, 2 * v, tl, mid);
            build(a, 2 * v + 1, mid + 1, tr);

            t[v] = Math.max(t[2 * v], t[2 * v + 1]);
        }

        void update(int v, int tl, int tr, int pos, int value) {
            if (tl == tr) {
                t[v] = value;
                return;
            }

            int mid = (tl + tr) / 2;

            if (pos <= mid) {
                update(2 * v, tl, mid, pos, value);
            } else {
                update(2 * v + 1, mid + 1, tr, pos, value);
            }

            t[v] = Math.max(t[2 * v], t[2 * v + 1]);
        }

        int getMax(int v, int tl, int tr, int l, int r) {
            if (l > r) {
                return -1000 * 1000;
            }
            if (tl == tr) {
                return t[v];
            }

            if (l == tl && r == tr) {
                return t[v];
            }

            int mid = (tl + tr) / 2;

            int max1 = getMax(2 * v, tl, mid, l, Math.min(mid, r));
            int max2 = getMax(2 * v + 1, mid + 1, tr, Math.max(mid + 1, l), r);

            return Math.max(max1, max2);
        }
    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        // TODO Auto-generated method stub
        new Template().run();
    }

    void run() throws NumberFormatException, IOException {
        solve();
        out.close();
    };

    BufferedReader in;
    PrintWriter out;

    StringTokenizer tok;
    String delim = " ";
    Random rnd = new Random();

    Template() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }

        }
        tok = new StringTokenizer("");
    }

    String readLine() throws IOException {
        return in.readLine();
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            String nextLine = readLine();
            if (null == nextLine) {
                return null;
            }

            tok = new StringTokenizer(nextLine);
        }
        return tok.nextToken();
    }

    int readInt() throws NumberFormatException, IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws NumberFormatException, IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(readString());
    }
}


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

      int n = sc.nextInt();
      int[] array = new int[n];
      for(int i = 0; i < n; i++){
         array[i] = sc.nextInt();
      }
      int count = 0;
      for(int i = 0; i < array.length; i++){
         for(int j = i+1; j < array.length; j++){
            if(array[i] > array[j]){
               count++;
            }
         }
      }
      count%=2;
      int q = sc.nextInt();
      for(int i = 0; i < q; i++){
         int l = sc.nextInt();
         int r = sc.nextInt();
         int sz = r - l + 1;
         count += (sz*(sz-1))/2;
         count %= 2;
         if(count == 1)
            System.out.println("odd");
         else
            System.out.println("even");
      }
   }
}


/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
		int[] A=new int[n];
		String[] s=br.readLine().split(" ");
		for(int i=0;i<n;i++){
			A[i]=Integer.parseInt(s[i]);
		}
		/*int[][] nck=new int[2000][2000];
		for(int i=0;i<=n;i++){
			for(int j=0;j<=n;j++){
				nck[i][j]=0;
			}
		}
		for(int i=0;i<=n;i++){
			nck[i][0]=1;
			for(int j=1;j<=i;j++){
				nck[i][j]=nck[i-1][j]+nck[i-1][j-1];
				nck[i][j]%=2;
			}
		}*/
		int inv=0;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(A[i]>A[j]){
					inv++;
				}
			}
		}
		StringBuilder sb=new StringBuilder("");
		int m=Integer.parseInt(br.readLine());
		for(int i=0;i<m;i++){
			s=br.readLine().split(" ");
			int li=Integer.parseInt(s[0]);
			int ri=Integer.parseInt(s[1]);
			int tot=ri-li+1;
			inv=inv+tot*(tot-1)/2;
			if(inv%2==0){
				sb.append("even\n");
			}
			else{
				sb.append("odd\n");
			}
		}
		System.out.print(sb);
	}
}


import java.util.*;
import java.io.*;
import java.util.Queue;
import java.util.LinkedList;
import java.math.*;

     public class Sample implements Runnable
    {

          public  static void solve()
          {
              int n=i();
              int[] a=new int[n];
              for(int i=0;i<n;i++)a[i]=i();
              int temp=0;
              for(int i=0;i<n;i++)
              {
                for(int j=i+1;j<n;j++)
                {
                  if(a[j]<a[i])temp++;
                }
              }
              boolean even=(temp%2==0)?true:false;
              int m=i();
              while(m-->0)
              {
               int l=i(); int r=i();
               long tt=(long)(Math.floor(r-l+1)/2);
               if(tt%2==1)
               {
                if(even)
                {
                  out.println("odd");
                  even=false;
                }
                else
                {
                  out.println("even");
                  even=true;
                }
               }else
               {
                if(even)
                {
                  out.println("even");

                }
                else
                {
                  out.println("odd");

                }
               }
              }

          }

          public void run()
          {
              solve();
              out.close();
          }

          public static void main(String[] args) throws IOException
          {
                new Thread(null, new Sample(), "whatever", 1<<26).start();
          }
         abstract static class Pair implements Comparable<Pair>
         {
            long a;
            int b;

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

            public int compareTo(Pair x)
           {
                return Long.compare(x.a,this.a);
           }
        }

    ////////////////////////////////////////////////////// Merge Sort ////////////////////////////////////////////////////////////////////////

   static class Merge
   {

        public static void sort(long inputArr[])
        {
            int length = inputArr.length;
            doMergeSort(inputArr,0, length - 1);
        }

        private static void doMergeSort(long[] arr,int lowerIndex, int higherIndex)
        {
            if (lowerIndex < higherIndex) {
                int middle = lowerIndex + (higherIndex - lowerIndex) / 2;
                doMergeSort(arr,lowerIndex, middle);
                doMergeSort(arr,middle + 1, higherIndex);
                mergeParts(arr,lowerIndex, middle, higherIndex);
            }
        }

        private static void mergeParts(long[]array,int lowerIndex, int middle, int higherIndex)
        {
            long[] temp=new long[higherIndex-lowerIndex+1];
            for (int i = lowerIndex; i <= higherIndex; i++)
            {
                temp[i-lowerIndex] = array[i];
            }
            int i = lowerIndex;
            int j = middle + 1;
            int k = lowerIndex;
            while (i <= middle && j <= higherIndex)
            {
                if (temp[i-lowerIndex] < temp[j-lowerIndex])
                {
                    array[k] = temp[i-lowerIndex];
                    i++;
                } else {
                    array[k] = temp[j-lowerIndex];
                    j++;
                }
                k++;
            }
            while (i <= middle)
            {
                array[k] = temp[i-lowerIndex];
                k++;
                i++;
            }
            while(j<=higherIndex)
            {
                array[k]=temp[j-lowerIndex];
                k++;
                j++;
            }
        }

    }

    /////////////////////////////////////////////////////////// Methods ////////////////////////////////////////////////////////////////////////

     static boolean isPal(String s)
     {
        for(int i=0, j=s.length()-1;i<=j;i++,j--)
        {
                if(s.charAt(i)!=s.charAt(j)) return false;
        }
        return true;
     }
     static String rev(String s)
     {
                StringBuilder sb=new StringBuilder(s);
                sb.reverse();
                return sb.toString();
     }
     static int gcd(int a,int b){return (a==0)?b:gcd(b%a,a);}
     static long gcdExtended(long a,long b,long[] x)
     {

        if(a==0){
            x[0]=0;
            x[1]=1;
            return b;
        }
        long[] y=new long[2];
        long gcd=gcdExtended(b%a, a, y);

        x[0]=y[1]-(b/a)*y[0];
        x[1]=y[0];

        return gcd;
    }

     boolean findSum(int set[], int n, long sum)
    {
      if (sum == 0)
         return true;
      if (n == 0 && sum != 0)
         return false;
      if (set[n-1] > sum)
         return findSum(set, n-1, sum);
      return findSum(set, n-1, sum) ||findSum(set, n-1, sum-set[n-1]);
    }

      public static long modPow(long base, long exp, long mod)
     {
        base = base % mod;
        long result = 1;
        while (exp > 0)
       {
            if (exp % 2 == 1)
            {
                result = (result * base) % mod;
            }
            base = (base * base) % mod;
            exp = exp >> 1;
       }
        return result;
    }

    static long[] fac;
    static long[] inv;
    static long mod=(long)1e9+7;
    public static void cal()
    {
        fac = new long[1000005];
        inv = new long[1000005];
        fac[0] = 1;
        inv[0] = 1;
        for (int i = 1; i <= 1000000; i++)
        {
            fac[i] = (fac[i - 1] * i) % mod;
            inv[i] = (inv[i - 1] * modPow(i, mod - 2, mod)) % mod;
        }
    }

    public static long ncr(int n, int r)
    {
        return (((fac[n] * inv[r]) % mod) * inv[n - r]) % mod;
    }

////////////////////////////////////////// Input Reader ////////////////////////////////////////////////////////////////////////////////////////////////////

    static InputReader sc = new InputReader(System.in);
    static PrintWriter out= new PrintWriter(System.out);

    static class InputReader {

          private final InputStream stream;
          private final byte[] buf = new byte[8192];
          private int curChar, snumChars;
          private SpaceCharFilter filter;

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

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

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

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

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

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

          public String nextLine()
         {
                  int c = snext();
                  while (isSpaceChar(c))
                          c = snext();
                  StringBuilder res = new StringBuilder();
                  do {
                          res.appendCodePoint(c);
                          c = snext();
                  } while (!isEndOfLine(c));
                  return res.toString();
          }

          public boolean isSpaceChar(int c)
          {
                  if (filter != null)
                          return filter.isSpaceChar(c);
                  return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
          }

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

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

    }

    static int i()
    {
        return sc.nextInt();
    }
    static long l(){
        return sc.nextLong();
    }
    static int[] iarr(int n)
    {
        return sc.nextIntArray(n);
    }
    static long[] larr(int n)
    {
        return sc.nextLongArray(n);
    }
    static String s(){
        return sc.nextLine();
    }

 }


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.io.InputStream;

public class BuildIn {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }
    public static void solve(InputReader in, PrintWriter out) throws IOException
    {
    	int n = in.nextInt();
    	int[] list = new int[n];
    	for(int i = 0; i < n; i++)
    	{
    		list[i]=in.nextInt();
    	}

    	int count = 0;
    	for(int i = 0; i < n-1; i++)
    	{
    		for(int j = i+1; j < n; j++)
    		{
    			if(list[j]<list[i])
    			{
    				count++;
    			}
    		}
    	}

    	boolean sta = true;
    	if(count%2==1) sta = false;

    	int m =  in.nextInt();
    	for(int i = 0; i <m; i++)
    	{
    		int a = in.nextInt();
    		int b = in.nextInt();
    		if((b-a)%4==2) sta = !sta;
    		if((b-a)%4==1) sta = !sta;
    		if(sta) out.println("even");
    		else out.println("odd");
    	}
	}

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

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

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

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

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

	    }
}


import java.util.Scanner;

public class TaskD {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = s.nextInt();
		}
		int m = s.nextInt();

		int inv = 0;
		// count inversions
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (a[i] > a[j]) {
					inv++;
				}
			}
		}

		boolean odd = (inv % 2 == 1);

		for (int i = 0; i < m; i++) {
			int l = s.nextInt();
			int r = s.nextInt() + 1; // r excluding, l including
			int num = (r - l)*(r - l - 1)/2;
			if (num % 2 == 1) {
				odd = !odd;
			}
			System.out.println((odd) ? "odd" : "even");
		}
	}

}


import java.util.*;

public class vas2 {
    public static void main( String[] args ) {
	Scanner in = new Scanner( System.in );
	int n = in.nextInt();
	String st = in.next();
	int[] a = new int[n];
	for ( int i = 0; i < n; i++ )
	    a[i] = st.charAt( i ) - 48;
	boolean c = false;
	for ( int i = 1; !c && i < n; i++ ) {
	    int s = 0;
	    for ( int j = 0; j < i; j++ )
		s += a[j];
	    int t = 0;
	    for ( int j = i; j < n; j++ ) {
		t += a[j];
		if ( t > s )
		    if ( t - a[j] != s )
			break;
		    else
			t = a[j];
	    }
	    if ( t == s )
		c = true;
	}
	System.out.println( c ? "YES" : "NO" );
    }
}


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

public class Main{

	static ArrayList a[]=new ArrayList[200001];
	static int Count(int a[][],int n) {
		dsu d=new dsu(n);
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++) {
				if(a[i][j]==0) {
					d.union(i, j);
				}
			}
		}
		int cnt=0;
		boolean chk[]=new boolean [n];
		for(int i=0;i<n;i++) {
			int p=d.root(i);
			if(!chk[p]) {
				chk[p]=true;
				cnt++;
			}
		}
	    return cnt;
	}
	public void solve () {
		InputReader in = new InputReader(System.in);
	    PrintWriter pw = new PrintWriter(System.out);
	    int n=in.nextInt();
	    int a=in.nextInt();
	    int b=in.nextInt();
	    if(a==1 || b==1) {
	    	int ans[][]=new int [n][n];
	    	int temp=(a==1)?b:a;
	    	for(int i=1;i<=n-temp;i++) {
	    		ans[i][i-1]=1;
	    		ans[i-1][i]=1;
	    	}
	    	int freq=Count(ans,n);
	    	if(freq!=1) {
	    		pw.println("NO");
	    	}
	    	else {
	    		pw.println("YES");
	    		for(int i=0;i<n;i++) {
	    			for(int j=0;j<n;j++) {
	    				if(i==j) {
	    					pw.print(0);
	    				}
	    				else
	    					pw.print((ans[i][j]+((temp==b)?1:0))%2);
	    			}
	    			pw.println();
	    		}
	    	}
	    }
	    else {
	    	pw.print("NO");
	    }
		pw.flush();
		pw.close();
	}
	public static void main(String[] args) throws Exception {

        new Thread(null,new Runnable() {
        	public void run() {
        		new Main().solve();
        	}
        },"1",1<<26).start();

    }
    static void debug(Object... o) {
    	System.out.println(Arrays.deepToString(o));
        }

        static class InputReader
        {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;

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

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

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

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

        public String readString()
        {
            int c = snext();
            while (isSpaceChar(c))
            {
                c = snext();
            }
            StringBuilder res = new StringBuilder();
            do
            {
                res.appendCodePoint(c);
                c = snext();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public String nextLine()
        {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            StringBuilder res = new StringBuilder();
            do
            {
                res.appendCodePoint(c);
                c = snext();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c)
        {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

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

        public interface SpaceCharFilter
        {
            public boolean isSpaceChar(int ch);
        }
    }
        public static long mod = 1000000007;
        public static int d;
        public static int p;
        public static int q;
        public void extended(int a,int b) {
        	if(b==0) {
        		d=a;
        		p=1;
        		q=0;
        	}
        	else
        	{
        		extended(b,a%b);
        		int temp=p;
        		p=q;
        		q=temp-(a/b)*q;
        	}
        }
        public static long[] shuffle(long[] a,Random gen)
        {
            int n = a.length;
            for(int i=0;i<n;i++)
            {
                int ind = gen.nextInt(n-i)+i;
                long temp = a[ind];
                a[ind] = a[i];
                a[i] = temp;
            }
            return a;
        }

        public static void swap(int a, int b){
            int temp = a;
            a = b;
            b = temp;
        }

        public static HashSet<Integer> primeFactorization(int n)
        {
            HashSet<Integer> a =new HashSet<Integer>();
            for(int i=2;i*i<=n;i++)
            {
                while(n%i==0)
                {
                    a.add(i);
                    n/=i;
                }
            }
            if(n!=1)
                a.add(n);
            return a;
        }

        public static void sieve(boolean[] isPrime,int n)
        {
            for(int i=1;i<n;i++)
                isPrime[i] = true;

            isPrime[0] = false;
            isPrime[1] = false;

            for(int i=2;i*i<n;i++)
            {
                if(isPrime[i] == true)
                {
                    for(int j=(2*i);j<n;j+=i)
                        isPrime[j] = false;
                }
            }
        }

        public static int GCD(int a,int b)
        {
            if(b==0)
                return a;
            else
                return GCD(b,a%b);
        }

        static class pair implements Comparable<pair>
        {
            Integer x;
            Long y;
            pair(int x,long y)
            {
                this.x=x;
                this.y=y;

            }

            public int compareTo(pair o) {
                int result = x.compareTo(o.x);
                if(result==0)
                    result = y.compareTo(o.y);

                return result;
            }

            public String toString()
            {
                return x+" "+y;
            }

            public boolean equals(Object o)
            {
                if (o instanceof pair)
                {
                    pair p = (pair)o;
                    return p.x == x && p.y == y ;
                }
                return false;
            }

            public int hashCode()
            {
                return new Long(x).hashCode()*31 + new Long(y).hashCode();
            }
        }

}
class pair implements Comparable<pair>
{
    Integer x;
    Long y;
    pair(int x,long y)
    {
        this.x=x;
        this.y=y;

    }

    public int compareTo(pair o) {
        int result = x.compareTo(o.x);
        if(result==0)
            result = y.compareTo(o.y);

        return result;
    }

    public String toString()
    {
        return x+" "+y;
    }

    public boolean equals(Object o)
    {
        if (o instanceof pair)
        {
            pair p = (pair)o;
            return p.x == x && p.y == y ;
        }
        return false;
    }

    public int hashCode()
    {
        return new Long(x).hashCode()*31 + new Long(y).hashCode();
    }
}
class dsu{
	int parent[];
	dsu(int n){
		parent=new int[n+1];
		for(int i=0;i<=n;i++)
		{
			parent[i]=i;
		}
	}
	int root(int n) {
		while(parent[n]!=n)
		{
			parent[n]=parent[parent[n]];
			n=parent[n];
		}
		return n;
	}
	void union(int _a,int _b) {
		int p_a=root(_a);
		int p_b=root(_b);

			parent[p_a]=p_b;

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

}


/**
 * @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>();
        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.add(new Pair(i, j, sum));
            }
        }
        Collections.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 < sums.size()) {
            int j = i;
            var group = new ArrayList(List.of(sums.get(i)));
            int last = sums.get(i).r;
            while (j + 1 < sums.size() && sums.get(j + 1).sum == sums.get(j).sum) {
                if (sums.get(j + 1).l > last) {
                    group.add(sums.get(j + 1));
                    last = sums.get(j + 1).r;
                }
                j++;
            }
//            System.out.println(group);
            if (group.size() > ans.size()) {
                ans = group;
            }
            i = j + 1;
        }
        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.*;
import java.util.*;
import java.util.function.BinaryOperator;
import java.util.stream.IntStream;

public class Main {
    private static InputReader reader = new InputReader(System.in);
    private static PrintWriter writer = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = readInt();
        long[] a = readLongArray(n);
        HashMap<Long, List<Block>> blocks = new HashMap<>();
        for (int j = 0; j < n; j++) {
            long sum = 0;
            for (int i = j; i >= 0; i--) {
                sum += a[i];
                if (!blocks.containsKey(sum))
                    blocks.put(sum, new LinkedList<>());
                List<Block> blockList = blocks.get(sum);
                if (blockList.size() > 0 && blockList.get(blockList.size() - 1).r == j) continue;
                blockList.add(new Block(i, j));
            }
        }

        List<Block> bestBlocks = new LinkedList<>();
        for(long sum : blocks.keySet()) {
            List<Block> blockList = blocks.get(sum);
            List<Block> curBest = new LinkedList<>();
            int lastR = -1;
            for(Block block : blockList) {
                if (block.l > lastR) {
                    curBest.add(block);
                    lastR = block.r;
                }
            }
            if (curBest.size() > bestBlocks.size()) {
                bestBlocks = curBest;
            }
        }

        writer.println(bestBlocks.size());
        for(Block block : bestBlocks) {
            writer.printf("%d %d\n", block.l + 1, block.r + 1);
        }

        writer.flush();
    }

    private static int readInt() {
        return reader.nextInt();
    }

    private static long readLong() {
        return Long.parseLong(reader.next());
    }

    private static int[] readIntArray(int size) {
        int[] array = new int[size];
        for (int i = 0; i < size; i++) {
            array[i] = readInt();
        }
        return array;
    }

    private static long[] readLongArray(int size) {
        long[] array = new long[size];
        for (int i = 0; i < size; i++) {
            array[i] = readLong();
        }
        return array;
    }

    private static void reverseIntArray(int[] array) {
        for (int i = 0; i < array.length / 2; i++) {
            int temp = array[i];
            array[i] = array[array.length - i - 1];
            array[array.length - i - 1] = temp;
        }
    }

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

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

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

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

    }

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


// package codeforce.Training1900;

import java.io.PrintWriter;
import java.util.*;
//https://codeforces.com/problemset/problem/1141/F2

public class SameSumBlocks {
    //    MUST SEE BEFORE SUBMISSION
//    check whether int part would overflow or not, especially when it is a * b!!!!

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
//        int t = sc.nextInt();
        int t = 1;
        for (int i = 0; i < t; i++) {
            solve(sc, pw);
        }
        pw.close();
    }

    static void solve(Scanner in, PrintWriter out){
        int n = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        Map<Long, List<int[]>> mp = new HashMap<>();
        long[] pre = new long[n + 1];
        for (int i = 1; i <= n; i++) {
            pre[i] = pre[i - 1] + arr[i - 1];
        }
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                long sz = pre[j + 1] - pre[i];
                if (!mp.containsKey(sz)) mp.put(sz, new ArrayList<>());
                mp.get(sz).add(new int[]{i, j});
            }
        }
        int max = 0;
        List<int[]> ans = new ArrayList<>();
        for(List<int[]> ls : mp.values()){
            Collections.sort(ls, (a, b) -> {
                if (a[1] == b[1]) return b[0] - a[0];
                return a[1] - b[1];
            });
            List<int[]> tt = new ArrayList<>();
            int cnt = 0;
            int pr = -1;
            for (int i = 0; i < ls.size(); i++) {
                int[] get = ls.get(i);
                if (get[0] <= pr) continue;
                cnt++;
                tt.add(get);
                pr = get[1];
            }
            if (max < cnt){
                ans = tt;
                max = cnt;
            }
        }
        out.println(max);
        for(int[] v : ans){
            out.println((v[0] + 1) + " " + (v[1] + 1));
        }
    }
}


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.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author revanth
 */
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);
            HashMap<Long, ArrayList<Pair>> hm = new HashMap<>();
            long sum;
            for (int j = 0; j < n; j++) {
                sum = 0;
                for (int i = j; i >= 0; i--) {
                    sum += a[i];
                    if (!hm.containsKey(sum))
                        hm.put(sum, new ArrayList<>());
                    hm.get(sum).add(new Pair(i + 1, j + 1));
                }
            }
            ArrayList<Pair> al1 = new ArrayList<>();
            ArrayList<Pair> al2 = new ArrayList<>();
            int prev;
            for (ArrayList<Pair> al : hm.values()) {
                prev = 0;
                al1.clear();
                for (Pair p : al) {
                    if (p.x > prev) {
                        al1.add(p);
                        prev = p.y;
                    }
                }
                if (al1.size() > al2.size())
                    al2 = new ArrayList<>(al1);
            }
            out.println(al2.size());
            for (Pair p : al2)
                out.println(p.x + " " + p.y);
        }

    }

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

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

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

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

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

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

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

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

        }

    }

    static class Pair implements Comparable<Pair> {
        public int x;
        public int y;

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

        public boolean equals(Object obj) {
            if (obj == null)
                return false;
            if (obj == this)
                return true;
            if (!(obj instanceof Pair))
                return false;
            Pair o = (Pair) obj;
            return o.x == this.x && o.y == this.y;
        }

        public int hashCode() {
            return this.x + this.y;
        }

        public int compareTo(Pair p) {
            if (x == p.x)
                return Integer.compare(y, p.y);
            return Integer.compare(x, p.x);
        }

    }

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

    }
}


import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.InputMismatchException;

public class F547 {

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

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

		long[] sum = new long[arr.length + 1];
		for(int i = 1; i < sum.length; i++)
			sum[i] = sum[i-1] + arr[i-1];

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

		for(int i = 0; i < sum.length; i++) {
			for(int j = i+1; j < sum.length; j++) {
				long diff = sum[j] - sum[i];

				if(!map.containsKey(diff))
					map.put(diff, new ArrayList<>());

				ArrayList<Pair> list = map.get(diff);
				list.add(new Pair(i, j));
			}
		}

		for(long key : map.keySet()) {
			ArrayList<Pair> list1 = map.get(key);
			Collections.sort(list1);

			ArrayList<Pair> list2 = new ArrayList<>();

			int end = 0;
			for(Pair p : list1) {
				if(end <= p.a) {
					list2.add(p);
					end = p.b;
				}
			}

			map.put(key, list2);
		}

		long maxKey = -1;
		int max = -1;
		for(long key : map.keySet()) {
			if(map.get(key).size() > max) {
				max = map.get(key).size();
				maxKey = key;
			}
		}

		ArrayList<Pair> list = map.get(maxKey);
		StringBuilder sb = new StringBuilder();
		sb.append(list.size());
		sb.append("\n");

		for(Pair p : list) {
			sb.append((1 + p.a) + " " + p.b);
			sb.append("\n");
		}

		System.out.println(sb.toString());
	}

	static class Pair implements Comparable<Pair> {
		int a, b;

		public Pair(int x, int y) {
			a = x;
			b = y;
		}

		public int compareTo(Pair other) {
			if(b != other.b) {
				return b - other.b;
			}
			return other.a - a;
		}

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

	/**
	 * Source: Matt Fontaine
	 */
	static class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int chars;

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

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

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

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

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

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

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

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

		public String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}

}
/*
7
4 1 2 2 1 5 3
outputCopy
3
7 7
2 3
4 5
inputCopy
11
-5 -4 -3 -2 -1 0 1 2 3 4 5
outputCopy
2
3 4
1 1
inputCopy
4
1 1 1 1
outputCopy
4
4 4
1 1
2 2
3 3
*/


import java.util.Scanner;
import java.util.Vector;
import java.util.HashMap;
import java.util.Comparator;

public class F2{
	static class Pair{
		int l;
		int r;
		Pair(int l, int r){
			this.l = l;
			this.r = r;
		}
		public String toString(){
			return "(" + l + ", " + r + ")";
		}
	}
	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();
		}
		HashMap<Integer, Vector<Pair>> map = new HashMap<>();
		for(int i = 1;i<=n;++i){
			int sum = 0;
			for(int j = i;j<=n;++j){
				sum+=a[j];
				if(!map.containsKey(sum))
					map.put(sum,new Vector<>());
				map.get(sum).add(new Pair(i,j));
			}
		}
		Vector<Pair> an = null;
		for(Integer key : map.keySet()){
			Vector<Pair> vec = map.get(key);
			Vector<Pair> ans = new Vector<>();
			ans.add(vec.get(0));
			int size = 1;
			for(int i = 1;i<vec.size();++i){
				if(ans.get(size-1).r > vec.get(i).r)
					ans.set(size-1,vec.get(i));
				else if(ans.get(size-1).r < vec.get(i).l){
					ans.add(vec.get(i));
					size++;
				}
			}
			if(an == null || an.size() < size) an = ans;
		}
		StringBuilder res = new StringBuilder().append(an.size() + "\n");
		for(int i = 0;i<an.size();++i)
			res.append(an.get(i).l + " " + an.get(i).r + "\n");
		System.out.println(res);
	}
}


import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.regex.*;
import java.util.stream.LongStream;

public class Main{

	static ArrayList a[]=new ArrayList[5000001];
	static Vector<pair>schedule_it(ArrayList<pair> v) {
		Vector<pair >ans=new Vector<>();
		Collections.sort(v, new Comparator<pair>() {
			public int compare(pair p1,pair p2) {
				if(p1.y<p2.y)
					return -1;
				if(p1.y>p2.y)
					return 1;
				if(p1.x<p2.x)
					return -1;
				if(p1.x>p2.x)
					return 1;
				return 0;
			}
		});
		int end=-1;
		for(int i=0;i<v.size();i++) {
			pair p=v.get(i);
			if(p.x>end) {
				ans.add(p);
				end=p.y;
			}
		}
		return ans;
	}
	public static void main(String[] args)
   {
       InputReader in=new InputReader(System.in);
       PrintWriter pw = new PrintWriter(System.out);
       int n=in.nextInt();
       long arr[]=new long[n];
       for(int i=0;i<n;i++) {
    	   arr[i]=in.nextLong();
       }
       HashMap<Long,Integer>hm=new HashMap<>();
       int id=0;
       for(int i=0;i<n;i++) {
    	   long sum=0;
    	   for(int j=i;j<n;j++) {
    		   sum+=arr[j];
    		   if(!hm.containsKey(sum)) {
    			   hm.put(sum, id++);
    			   a[id-1]=new ArrayList<pair>();
    		   }
    		   a[hm.get(sum)].add(new pair(i,j));
    	   }
       }
       Vector<pair>fi=new Vector<>();
       for(int i=0;i<id;i++) {
    	  Vector<pair> v=schedule_it(a[i]);
    	   if(v.size()>fi.size()) {
    		   fi=v;
    	   }
       }
       pw.println(fi.size());
       for(int i=0;i<fi.size();i++) {
    	   pw.println((fi.get(i).x+1)+" "+(fi.get(i).y+1));
       }
       pw.flush();
       pw.close();

    }
         private static void debug(Object... o) {
     		System.out.println(Arrays.deepToString(o));
     	}
        static class InputReader
        {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream)
        {
            this.stream = stream;
        }
        public int snext()
        {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars)
            {
                curChar = 0;
                try
                {
                    snumChars = stream.read(buf);
                }

                catch (IOException e)
                {
                    throw new InputMismatchException();
                }

                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

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

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

        public int[] nextIntArray(int n)
        {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = nextInt();
            }
            return a;
        }
        static class tri implements Comparable<tri> {
            int p, c, l;

            tri(int p, int c, int l) {
                this.p = p;
                this.c = c;
                this.l = l;
            }

            public int compareTo(tri o) {
                return Integer.compare(l, o.l);
            }
        }

        public String readString()
        {
            int c = snext();
            while (isSpaceChar(c))
            {
                c = snext();
            }
            StringBuilder res = new StringBuilder();
            do
            {
                res.appendCodePoint(c);
                c = snext();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public String nextLine()
        {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            StringBuilder res = new StringBuilder();
            do
            {
                res.appendCodePoint(c);
                c = snext();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c)
        {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

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

        public interface SpaceCharFilter
        {
            public boolean isSpaceChar(int ch);
        }
    }
        public static long mod = 1000000007;
        public static int d;
        public static int p;
        public static int q;

        public static int[] suffle(int[] a,Random gen)
        {
            int n = a.length;
            for(int i=0;i<n;i++)
            {
                int ind = gen.nextInt(n-i)+i;
                int temp = a[ind];
                a[ind] = a[i];
                a[i] = temp;
            }
            return a;
        }

        public static void swap(int a, int b){
            int temp = a;
            a = b;
            b = temp;
        }

       /* public static long primeFactorization(long n)
        {
             HashSet<Integer> a =new HashSet<Integer>();
        	long cnt=0;
            for(int i=2;i*i<=n;i++)
            {
                while(a%i==0)
                {
                    a.add(i);
                    a/=i;
                }
            }
            if(a!=1)
            	cnt++;
                //a.add(n);
            return cnt;
        }*/

        public static void sieve(boolean[] isPrime,int n)
        {
            for(int i=1;i<n;i++)
                isPrime[i] = true;

            isPrime[0] = false;
            isPrime[1] = false;

            for(int i=2;i*i<n;i++)
            {
                if(isPrime[i] == true)
                {
                    for(int j=(2*i);j<n;j+=i)
                        isPrime[j] = false;
                }
            }
        }

        public static int GCD(int a,int b)
        {
            if(b==0)
                return a;
            else
                return GCD(b,a%b);
        }

        public static long GCD(long a,long b)
        {
            if(b==0)
                return a;
            else
                return GCD(b,a%b);
        }

        public static void extendedEuclid(int A,int B)
        {
            if(B==0)
            {
                d = A;
                p = 1 ;
                q = 0;
            }
            else
            {
                extendedEuclid(B, A%B);
                int temp = p;
                p = q;
                q = temp - (A/B)*q;
            }
        }

        public static long LCM(long a,long b)
        {
            return (a*b)/GCD(a,b);
        }

        public static int LCM(int a,int b)
        {
            return (a*b)/GCD(a,b);
        }

        public static int binaryExponentiation(int x,int n)
        {
            int result=1;
            while(n>0)
            {
                if(n % 2 ==1)
                    result=result * x;
                x=x*x;
                n=n/2;
            }
            return result;
        }

        public static long binaryExponentiation(long x,long n)
        {
            long result=1;
            while(n>0)
            {
                if(n % 2 ==1)
                    result=result * x;
                x=x*x;
                n=n/2;
            }
            return result;
        }

        public static int modularExponentiation(int x,int n,int M)
        {
            int result=1;
            while(n>0)
            {
                if(n % 2 ==1)
                    result=(result * x)%M;
                x=(x%M*x)%M;
                n=n/2;
            }
            return result;
        }

        public static long modularExponentiation(long x,long n,long M)
        {
            long result=1;
            while(n>0)
            {
                if(n % 2 ==1)
                    result=(result%M * x%M)%M;
                x=(x%M * x%M)%M;
                n=n/2;
            }
            return result;
        }

        public static long modInverse(int A,int M)
        {
            return modularExponentiation(A,M-2,M);
        }

        public static long modInverse(long A,long M)
        {
            return modularExponentiation(A,M-2,M);
        }

        public static boolean isPrime(int n)
        {

            if (n <= 1)  return false;
            if (n <= 3)  return true;

            if (n%2 == 0 || n%3 == 0)
                return false;

            for (int i=5; i*i<=n; i=i+6)
            {
                if (n%i == 0 || n%(i+2) == 0)
                   return false;
            }

            return true;
        }

         public static long[] shuffle(long[] a, Random gen){
                for(int i = 0, n = a.length;i < n;i++){
                    int ind = gen.nextInt(n-i)+i;
                    long d = a[i];
                    a[i] = a[ind];
                    a[ind] = d;
                }
                return a;
            }
         static class pair implements Comparable<pair>{
             Integer x;
             Integer y;
             pair(int l,int id){
                 this.x=l;
                 this.y=id;
             }
              public int compareTo(pair o) {
                     int result = x.compareTo(o.x);
                     if(result==0)
                         result = y.compareTo(o.y);

                 return result;
                 }
              public String toString(){
                 return (x+" "+y);
             }
       }

}


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

public class Codeforces {

    static long MOD = 1_000_000_007L;

    static void main2() throws Exception {
        int n = ni();
        int[] arr = nia(n);
        Map<Integer, List<Pair<Integer, Integer>>> map = new HashMap<>();
        for(int r = 0; r < n; r++) {
            int sum = 0;
            for(int l = r; l >= 0; l--) {
                sum += arr[l];
                if(!map.containsKey(sum)) map.put(sum, new ArrayList<Pair<Integer, Integer>>());
                map.get(sum).add(new Pair<Integer, Integer>(l + 1, r + 1));
            }
        }
        int bestSum = Integer.MIN_VALUE;
        int bestSumCount = -1;
        for(Map.Entry<Integer, List<Pair<Integer, Integer>>> entry : map.entrySet()) {
            int count = 0;
            int r = -1;
            for(Pair<Integer, Integer> pair : entry.getValue()) {
                if(r < pair.first) {
                    count++;
                    r = pair.second;
                }
            }
            if(count > bestSumCount) {
                bestSumCount = count;
                bestSum = entry.getKey();
            }
        }
        //got best sum
        println(bestSumCount);
        int r = -1;
        for(Pair<Integer, Integer> pair : map.get(bestSum)) {
            if(r < pair.first) {
                println(pair.first + " " + pair.second);
                r = pair.second;
            }
        }
    }

    // ____________________________________________________________________________
    //|                                                                            |
    //|  /$$$$$$  /$$$$$$         /$$$$$$   /$$                /$$$$$$   /$$$$$$   |
    //| |_  $$_/ /$$__  $$       /$$__  $$ | $$               /$$__  $$ /$$__  $$  |
    //|   | $$  | $$  \ $$      | $$  \__//$$$$$$   /$$   /$$| $$  \__/| $$  \__/  |
    //|   | $$  | $$  | $$      |  $$$$$$|_  $$_/  | $$  | $$| $$$$    | $$$$      |
    //|   | $$  | $$  | $$       \____  $$ | $$    | $$  | $$| $$_/    | $$_/      |
    //|   | $$  | $$  | $$       /$$  \ $$ | $$ /$$| $$  | $$| $$      | $$        |
    //|  /$$$$$$|  $$$$$$/      |  $$$$$$/ |  $$$$/|  $$$$$$/| $$      | $$        |
    //| |______/ \______/        \______/   \___/   \______/ |__/      |__/        |
    //|____________________________________________________________________________|

    private static byte[] scannerByteBuffer = new byte[1024]; // Buffer of Bytes
    private static int scannerIndex;
    private static InputStream scannerIn;
    private static int scannerTotal;
    private static BufferedWriter printerBW;
    private static boolean DEBUG = false;

    private static int next() throws IOException { // Scan method used to scan buf
        if (scannerTotal < 0)
            throw new InputMismatchException();
        if (scannerIndex >= scannerTotal) {
            scannerIndex = 0;
            scannerTotal = scannerIn.read(scannerByteBuffer);
            if (scannerTotal <= 0)
                return -1;
        }
        return scannerByteBuffer[scannerIndex++];
    }

    static int ni() throws IOException {
        int integer = 0;
        int n = next();
        while (isWhiteSpace(n)) // Removing startPointing whitespaces
            n = next();
        int neg = 1;
        if (n == '-') { // If Negative Sign encounters
            neg = -1;
            n = next();
        }
        while (!isWhiteSpace(n)) {
            if (n >= '0' && n <= '9') {
                integer *= 10;
                integer += n - '0';
                n = next();
            } else
                throw new InputMismatchException();
        }
        return neg * integer;
    }

    static long nl() throws IOException {
        long integer = 0;
        int n = next();
        while (isWhiteSpace(n)) // Removing startPointing whitespaces
            n = next();
        int neg = 1;
        if (n == '-') { // If Negative Sign encounters
            neg = -1;
            n = next();
        }
        while (!isWhiteSpace(n)) {
            if (n >= '0' && n <= '9') {
                integer *= 10;
                integer += n - '0';
                n = next();
            } else
                throw new InputMismatchException();
        }
        return neg * integer;
    }

    static String line() throws IOException {
        StringBuilder sb = new StringBuilder();
        int n = next();
        while (isWhiteSpace(n))
            n = next();
        while (!isNewLine(n)) {
            sb.append((char) n);
            n = next();
        }
        return sb.toString();
    }

    private static boolean isNewLine(int n) {
        return n == '\n' || n == '\r' || n == -1;
    }

    private static boolean isWhiteSpace(int n) {
        return n == ' ' || isNewLine(n) || n == '\t';
    }

    static int[] nia(int n) throws Exception {
        if (n < 0)
            throw new Exception("Array size should be non negative");
        int[] array = new int[n];
        for (int i = 0; i < n; i++)
            array[i] = ni();
        return array;
    }

    static int[][] n2dia(int r, int c) throws Exception {
        if (r < 0 || c < 0)
            throw new Exception("Array size should be non negative");
        int[][] array = new int[r][c];
        for (int i = 0; i < r; i++)
            array[i] = nia(c);
        return array;
    }

    static long[] nla(int n) throws Exception {
        if (n < 0)
            throw new Exception("Array size should be non negative");
        long[] array = new long[n];
        for (int i = 0; i < n; i++)
            array[i] = nl();
        return array;
    }

    static float[] nfa(int n) throws Exception {
        if (n < 0)
            throw new Exception("Array size should be non negative");
        float[] array = new float[n];
        for (int i = 0; i < n; i++)
            array[i] = nl();
        return array;
    }

    static double[] nda(int n) throws Exception {
        if (n < 0)
            throw new Exception("Array size should be non negative");
        double[] array = new double[n];
        for (int i = 0; i < n; i++)
            array[i] = nl();
        return array;
    }

    static <T> void print(T ... str) {
        try {
            for(T ele : str)
                printerBW.append(ele.toString());
            if (DEBUG)
                flush();
        } catch (IOException e) {
            System.out.println(e.toString());
        }
    }

    static <T> void println(T ... str) {
        if(str.length == 0) {
            print('\n');
            return;
        }
        for(T ele : str)
            print(ele, '\n');
    }

    static void flush() throws IOException {
        printerBW.flush();
    }

    static void close() {
        try {
            printerBW.close();
        } catch (IOException e) {
            System.out.println(e.toString());
        }
    }

    public static void main(String[] args) throws Exception {
        long startPointTime = System.currentTimeMillis();
        scannerIn = System.in;
        printerBW = new BufferedWriter(new OutputStreamWriter(System.out));
        if (args.length > 0 && args[0].equalsIgnoreCase("debug")
                || args.length > 1 && args[1].equalsIgnoreCase("debug"))
            DEBUG = true;

        main2();
        long endTime = System.currentTimeMillis();
        float totalProgramTime = endTime - startPointTime;
        if (args.length > 0 && args[0].equalsIgnoreCase("time") || args.length > 1 && args[1].equalsIgnoreCase("time"))
            print("Execution time is " + totalProgramTime + " (" + (totalProgramTime / 1000) + "s)");
        close();
    }

    static class Pair <L, R> {
        L first;
        R second;

        Pair(L first, R second) {
            this.first = first;
            this.second = second;
        }

        public boolean equals(Object p2) {
            if (p2 instanceof Pair) {
                return ((Pair) p2).first.equals(first) && ((Pair) p2).second.equals(second);
            }
            return false;
        }

        public String toString() {
            return "(first=" + first.toString() + ",second=" + second.toString() + ")";
        }
    }

    static class DisjointSet {
        int[] arr;
        int[] size;

        DisjointSet(int n) {
            arr = new int[n + 1];
            size = new int[n + 1];
            makeSet();
        }

        void makeSet() {
            for (int i = 1; i < arr.length; i++) {
                arr[i] = i;
                size[i] = 1;
            }
        }

        void union(int i, int j) {
            if (i == j)
                return;
            if (i > j) {
                i ^= j;
                j ^= i;
                i ^= j;
            }

            i = find(i);
            j = find(j);

            if (i == j)
                return;
            arr[j] = arr[i];
            size[i] += size[j];
            size[j] = size[i];
        }

        int find(int i) {
            if (arr[i] != i) {
                arr[i] = find(arr[i]);
                size[i] = size[arr[i]];
            }
            return arr[i];
        }

        int getSize(int i) {
            i = find(i);
            return size[i];
        }

        public String toString() {
            return Arrays.toString(arr);
        }
    }

    static boolean isSqrt(double a) {
        double sr = Math.sqrt(a);
        return ((sr - Math.floor(sr)) == 0);
    }

    static long abs(long a) {
        return Math.abs(a);
    }

    static int min(int ... arr) {
        int min = Integer.MAX_VALUE;
        for (int var : arr)
            min = Math.min(min, var);
        return min;
    }

    static long min(long ... arr) {
        long min = Long.MAX_VALUE;
        for (long var : arr)
            min = Math.min(min, var);
        return min;
    }

    static int max(int... arr) {
        int max = Integer.MIN_VALUE;
        for (int var : arr)
            max = Math.max(max, var);
        return max;
    }

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


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

public class Main {

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

        new Main().go();
    }

    PrintWriter out;
    Reader in;
    BufferedReader br;

    Main() throws IOException {

        try {

            //br = new BufferedReader( new FileReader("input.txt") );
            //in = new Reader("input.txt");
            in = new Reader("input.txt");
            out = new PrintWriter( new BufferedWriter(new FileWriter("output.txt")) );
        }
        catch (Exception e) {

            //br = new BufferedReader( new InputStreamReader( System.in ) );
            in = new Reader();
            out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );
        }
    }

    void go() throws Exception {

        //int t = in.nextInt();
        int t = 1;
        while (t > 0) {
            solve();
            t--;
        }

        out.flush();
        out.close();
    }

    int inf = 2000000000;
    int mod = 1000000007;
    double eps = 0.000000001;

    int n;
    int m;

    ArrayList<Integer>[] g;
    int[] a;

    void solve() throws IOException {

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

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

        int max = 0;
        ArrayList<Pair> ans = new ArrayList<>();
        for (Integer k : segs.keySet()) {
            ArrayList<Pair> list = segs.get(k);
            ArrayList<Pair> blocks = new ArrayList<>();
            Collections.reverse(list);
            int prev = inf;
            for (Pair p : list) {
                int l = p.a;
                int r = p.b;
                if (r < prev) {
                    blocks.add(p);
                    prev = l;
                }
            }
            if (blocks.size() > max) {
                ans = blocks;
                max = blocks.size();
            }
        }
        out.println(ans.size());
        for (Pair p : ans)
            out.println((p.a+1)+" "+(p.b+1));
    }

    class Pair implements Comparable<Pair>{

        int a;
        int b;

        Pair(int a, int b) {

            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {
            if (a != p.a)
                return Integer.compare(a, p.a);
            else
                return Integer.compare(b, p.b);
        }
    }

    class Item {

        int a;
        int b;
        int c;

        Item(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

    }

    class Reader {

        BufferedReader  br;
        StringTokenizer tok;

        Reader(String file) throws IOException {
            br = new BufferedReader( new FileReader(file) );
        }

        Reader() throws IOException {
            br = new BufferedReader( new InputStreamReader(System.in) );
        }

        String next() throws IOException {

            while (tok == null || !tok.hasMoreElements())
                tok = new StringTokenizer(br.readLine());
            return tok.nextToken();
        }

        int nextInt() throws NumberFormatException, IOException {
            return Integer.valueOf(next());
        }

        long nextLong() throws NumberFormatException, IOException {
            return Long.valueOf(next());
        }

        double nextDouble() throws NumberFormatException, IOException {
            return Double.valueOf(next());
        }

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

    }

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

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

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

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

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

            if (neg)
                return -ret;
            return ret;
        }

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

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

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

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

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

}


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

public class default_dst {
    public static void main(String[] args) {
        in = new FastReader();
        int n=ni();
        int[] arr=takeIntegerArrayInput(n);
        HashMap<Long,ArrayList<pair>> hm=new HashMap<>();
        int max_size=0;
        long S=-1;
        for (int i=0;i<arr.length;i++){
            long sum=0;
            for (int j=i;j>=0;j--){
                sum+=arr[j];
                if (!hm.containsKey(sum)){
                    hm.put(sum,new ArrayList<>());
                }
                if (hm.get(sum).size()==0||hm.get(sum).get(hm.get(sum).size()-1).y<j){
                    hm.get(sum).add(new pair(j,i));
                }
                if (hm.get(sum).size()>max_size){
                    max_size=hm.get(sum).size();
                    S=sum;
                }

            }
        }
        System.out.println(max_size);
        StringBuilder sb=new StringBuilder();
        for (int i=0;i<hm.get(S).size();i++){
            sb.append(hm.get(S).get(i)).append("\n");
        }
        System.out.print(sb.toString());

    }
    static class pair{
        int x;
        int y;
        pair(int x,int y){
            this.x=x;
            this.y=y;
        }
        @Override
        public String toString(){
            return (this.x+1)+" "+(this.y+1);
        }
    }
    public static long binarySearch(long low, long high) {
        while (high - low > 1) {
            long mid = (high - low)/2 + low;
            //System.out.println(mid);
            if (works(mid)) {
                high = mid;
            } else {
                low = mid;
            }
        }
        return (works(low) ? low : high);
    }
    static long fast_exp_with_mod(long base, long exp) {
        long MOD=1000000000+7;
        long res=1;
        while(exp>0) {
            if(exp%2==1) res=(res*base)%MOD;
            base=(base*base)%MOD;
            exp/=2;
        }
        return res%MOD;
    }
    public static long gcd(long a, long b)
    {
        if (a == 0)
            return b;
        return gcd(b%a, a);
    }
    static class my_no{
        long num;
        long denom;

        @Override
        public String toString() {
            if (denom<0){
                this.num=-this.num;
                this.denom=-this.denom;
            }
            if (num==0)return "0";
            return (num+"/"+denom);
        }

        my_no(int no){
            this.num=no;
            this.denom=1;
        }
        my_no(long num,long denom){
            this.num=num;
            this.denom=denom;
        }

        my_no multiply(my_no obj){
            long num1=obj.num;
            long denom1=obj.denom;
            long n=num1*num;
            long d=denom1*denom;
            long gcd=gcd(n,d);
            n/=gcd;
            d/=gcd;
            return new my_no(n,d);

        }
//        my_no multiply(my_no obj){
//            long num1=obj.num;
//            long denom1=obj.denom;
//            long num2=this.num;
//            long denom2=this.denom;
//
//        }

        my_no multiply(int no){
            long n=num*no;
            long d=denom;
            long gcd=gcd(n,d);
            n/=gcd;
            d/=gcd;
            return new my_no(n,d);

        }
    }
    static void memset(int[][] arr,int val){
        for (int i=0;i<arr.length;i++){
            for (int j=0;j<arr[i].length;j++){
                arr[i][j]=val;
            }
        }
    }
    static void memset(int[] arr,int val){
        for (int i=0;i<arr.length;i++){
            arr[i]=val;
        }
    }

    static void memset(long[][] arr,long val){
        for (int i=0;i<arr.length;i++){
            for (int j=0;j<arr[i].length;j++){
                arr[i][j]=val;
            }
        }
    }
    static void memset(long[] arr,long val){
        for (int i=0;i<arr.length;i++){
            arr[i]=val;
        }
    }
    static private boolean works(long test){
        return true;
    }

    static void reverse(char[] arr ,int i,int j){
        if (i==j)
            return;
        while (i<j){
            char temp=arr[i];
            arr[i]=arr[j];
            arr[j]=temp;
            ++i;
            --j;
        }
    }
    static int[]  takeIntegerArrayInput(int no){
        int[] arr=new int[no];
        for (int i=0;i<no;++i){
            arr[i]=ni();
        }
        return arr;
    }
    static long fast_Multiply(long no , long pow){
        long result=1;
        while (pow>0){
            if ((pow&1)==1){
                result=result*no;
            }
            no=no*no;
            pow>>=1;
        }
        return result;
    }

    static long[]  takeLongArrayInput(int no){
        long[] arr=new long[no];
        for (int i=0;i<no;++i){
            arr[i]=ni();
        }
        return arr;
    }
    static final long MOD = (long)1e9+7;
    static FastReader in;

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

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

    static String n(){
        return in.next();
    }

    static String nln(){
        return in.nextLine();
    }

    static int ni(){
        return Integer.parseInt(in.next());
    }

    static int[] ia(int N){
        int[] a = new int[N];
        for(int i = 0; i<N; i++)a[i] = ni();
        return a;
    }

    static long[] la(int N){
        long[] a = new long[N];
        for(int i = 0; i<N; i++)a[i] = nl();
        return a;
    }

    static long nl(){
        return Long.parseLong(in.next());
    }

    static double nd(){
        return Double.parseDouble(in.next());
    }

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

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

        String nextLine(){
            String str = "";
            try{
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }
            return str;
        }
    }
    static void println(String[] arr){
        for (int i=0;i<arr.length;++i){
            System.out.println(arr[i]);
        }
    }

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Stack;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args) {
		Reader in = new Reader();
		int n = in.nextInt();
		int[] a = in.na(n);
		HashMap<Long, ArrayList<Pair>> v = new HashMap<>();
		for(int i = 0; i<n; i++) {
			long s  = 0;
			for(int j = i; j<n; j++) {
				s+=a[j];
				Pair p = new Pair(i+1, j+1);
				if(v.containsKey(s)) {
					v.get(s).add(p);
				}else {
					ArrayList<Pair> xd = new ArrayList<>();
					xd.add(p);
					v.put(s,xd);
				}
			}
		}
		ArrayList<Pair> ans = new ArrayList<>();
		for(Entry<Long,ArrayList<Pair>> e : v.entrySet()) {
			ArrayList<Pair> pairs = e.getValue();
			Collections.sort(pairs);
			Stack<Pair> st = new Stack<>();
			for(int i = 0; i<pairs.size(); i++) {
				Pair cur = pairs.get(i);
				if(st.isEmpty()||st.peek().r<cur.l) {
					st.push(cur);
				}else if(st.peek().r>cur.r) {
						st.pop();
						st.push(cur);
				}
				if(st.size()>ans.size()) ans = new ArrayList<>(st);
			}
		}
		System.out.println(ans.size());
		for(Pair p : ans)
			System.out.println(p.l +" "+p.r);
	}
	static class Pair implements Comparable<Pair>{
		int l,r;
		public Pair(int l, int r) {
			this.l = l;
			this.r = r;
		}
		@Override
		public int compareTo(Pair o) {
			return this.l - o.l;
		}
	}
	static class Reader {
		static BufferedReader br;
		static StringTokenizer st;

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

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

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

		public String[] nS(int n) {
			String[] a = new String[n];
			for (int i = 0; i < n; i++)
				a[i] = next();
			return a;
		}

		public int nextInt() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Integer.parseInt(st.nextToken());
		}

		public double nextDouble() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Double.parseDouble(st.nextToken());
		}

		public Long nextLong() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Long.parseLong(st.nextToken());
		}

		public String next() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return st.nextToken();
		}

		public static void readLine() {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
			}
		}
	}
}


import java.util.*;
import java.io.*;
import java.math.*;
public class Solution{

    static class Node implements Comparable<Node>{
        int sum;
        int l;
        int r;
        Node next;
        int nb;
        Node ini;
        boolean not;
        public Node(int sum,int l,int r){
            this.sum = sum;
            this.l = l;
            this.r = r;
            nb = 0;
            not = false;
            ini = null;
        }

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

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        PrintWriter out = new PrintWriter(System.out);

        int n = Integer.parseInt(st.nextToken());

        TreeSet<Node> ts = new TreeSet<Node>();

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

        int[] s = new int[n+1];
        for(int i=1;i<=n;i++) s[i] = s[i-1] + a[i];

        for(int i=1;i<=n;i++){
            for(int j=i;j<=n;j++){
                ts.add(new Node(s[j]-s[i-1],i,j));
            }
        }
        int minvalue = -2000*(int)Math.pow(10,5);
        int maxvalue = 2000*(int)Math.pow(10,5);
        ts.add(new Node(minvalue,0,0));
        ts.add(new Node(maxvalue,0,0));
        //System.out.println(minvalue);
        Node node = ts.higher(ts.first());

        int sum = 0;

        int max = 0;
        Node m = null;

        while(node.sum!=maxvalue){

            sum = node.sum;
            while(node.sum==sum){
                node = ts.higher(node);
            }

            Node var = ts.lower(node);
           // System.out.println(sum+" "+var.sum);
            max = 0;
            while(var.sum==sum){

                Node next = ts.higher(new Node(sum,var.r+1,0));

                if(max>1+next.nb){
                    var.nb = max;
                    var.ini = m;
                }
                else if(next.ini==null){

                    var.nb = 1 + next.nb;
                    var.next = next;
                    if(max<var.nb){
                        max = var.nb;
                        m = var;
                    }

                }else{

                    var.nb = 1 + next.nb;
                    var.next = next.ini;
                    if(max<var.nb){
                        max = var.nb;
                        m = var;
                    }

                }

                var = ts.lower(var);

                //System.out.println(sum+" "+var.sum);
            }

        }

        int k = 0;
        Node best = new Node(minvalue,0,0);

        //var = new Node(minvalue,0,0);
        for(Node var:ts){
            if(k<var.nb){
                k = var.nb;
                best = var;
                if(var.ini!=null) best = var.ini;
            }
        }

        if(k==0) System.out.println("erreur");
        else{

            out.println(k);
            sum = best.sum;
            while(best.sum==sum){
                out.println(best.l+" "+best.r);
                best = best.next;
            }

        }

        out.flush();

    }

}


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

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

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

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

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

        }

        static class Pair {
            int sum;
            int last;

        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

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

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

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

    }
}