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.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.Map.Entry;
import java.io.BufferedReader;
import java.io.InputStream;

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

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

            Map<Integer, List<Range>> rgs = new HashMap<Integer, List<Range>>();

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

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

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

            Iterator it = rgs.entrySet().iterator();
            List<Range> ans = new ArrayList<Range>();

            while (it.hasNext()) {
                Map.Entry pair = (Map.Entry) it.next();
                int sum = (int) pair.getKey();
                List<Range> ranges = rgs.get(sum);

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

                for (Range r : ranges) {
                    if (cand.size() == 0) {
                        cand.add(r);
                        continue;
        ... Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?