// Author: aman_robotics

//package math_codet;

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

public class lets_do {
    FastReader in;
    PrintWriter out;
    Helper_class h;
    final long mod = 1000000009;
    final int MAXN = 1000005;
    final int lgN = 20;
    final long INF = (long)1e18;
    final long MAX_Ai = (long)1e12;
    public static void main(String[] args) throws java.lang.Exception{
        new lets_do().run();
    }
    void run() throws Exception{
        in=new FastReader(System.in);
        out = new PrintWriter(System.out);
        h = new Helper_class();
        int t = 1;
        while(t--> 0)
            solve();
        out.flush();
        out.close();
    }
    void solve(){
        int n = h.ni();
        long[] arr = new long[n];
        int i = 0, j = 0;
        for(i = 0; i < n; i++)
            arr[i] = h.nl();
        HashMap<Long, Integer> hmap = new HashMap<Long, Integer>();
        int cnt = 0;
        for(i = 0; i < n; i++){
            long sum = 0;
            for(j = i; j < n; j++){
                sum += arr[j];
                Integer x = hmap.get(sum);
                if(x == null)
                    hmap.put(sum, cnt++);
            }
        }
        TreeSet<Pair>[] tset = new TreeSet[cnt];
        for(i = 0; i < cnt; i++)
            tset[i] = new TreeSet<Pair>(com);
        for(i = 0; i < n; i++){
            long sum = 0;
            for(j = i; j < n; j++){
                sum += arr[j];
                tset[hmap.get(sum)].add(new Pair(i, j));
            }
        }
        int max = 0;
        int ind = -1;
        int max_x = 0, max_y = 0;
        for(i = 0; i < cnt; i++){
        	int curr_y = tset[i].first().y;
        	int cnt1 = 1;
            for(Pair yo : tset[i]){
                if(yo.x > curr_y) {
                	cnt1++;
                	curr_y = yo.y;
                }
            }
            if(max < cnt1) {
            	max = cnt1;
            	ind = i;
            }
        }
        h.pn(max);
        Pair hola_yee = new... What is the time complexity of the previous code?