import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;

public class Main {

    static int[][] vis;

    static void solve(TreeMap<Integer, Integer>rmap, TreeMap<Integer, Integer>gmap, TreeMap<Integer, Integer>bmap){

    }

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

        Scanner sc = new Scanner(System.in);

        //int tests =sc.nextInt();
        int tests =1;
        OutputStream out = new BufferedOutputStream( System.out );
        for (int z=0;z<tests;z++) {
            int n ,x;
            n = sc.nextInt();
			int [] arr = new int[n];
			for (int i=0; i<n;i++){
				arr[i] = sc.nextInt();
			}
			long ans =0;
			HashSet<Integer > sum = new HashSet<>();
			int[] pref = new int[n+1];

			sum.add(0);
			for (int i=0;i<n;i++){
				pref[i+1] = pref[i] + arr[i];

			}
			int r=0;
			for (int l=0;l<n;l++){
				while (r<n && !sum.contains(pref[r+1])){
					r++;
					sum.add(pref[r]);
				}
				ans += (long)r-l;
				sum.remove(pref[l]);
			}
			System.out.println(ans);

        }

    }
}


import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;

public class Main {

    static int[][] vis;

    static void solve(TreeMap<Integer, Integer>rmap, TreeMap<Integer, Integer>gmap, TreeMap<Integer, Integer>bmap){

    }

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

        Scanner sc = new Scanner(System.in);

        //int tests =sc.nextInt();
        int tests =1;
        OutputStream out = new BufferedOutputStream( System.out );
        for (int z=0;z<tests;z++) {
            int n ,x;
            n = sc.nextInt();
			int [] arr = new int[n];
			for (int i=0; i<n;i++){
				arr[i] = sc.nextInt();
			}
			long ans =0;
			HashSet<Integer > sum = new HashSet<>();
			int[] pref = new int[n+1];

			sum.add(0);
			for (int i=0;i<n;i++){
				pref[i+1] = pref[i] + arr[i];

			}
			int r=1;
			for (int l=0;l<n;l++){
				r = Math.max(r, l+1);
				while (r<=n && !sum.contains(pref[r]-pref[l])){
					sum.add(pref[r]-pref[l]);
					r++;
				}
				ans += (long)r-l-1;
				if (pref[l]!=0)sum.remove(pref[l]);
			}
			System.out.println(ans);

        }

    }
}


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

// (int)

public class Codechef  {

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

		Scanner scn = new Scanner(System.in);
//		long t = scn.nextLong();
		long t = 1;
		while(t-->0) {

			long n = scn.nextLong();
//			long m = scn.nextLong();

			long[] a = new long[(int)n];
			for(int i = 0; i < n; i++) {
				a[i] = scn.nextLong();
			}

			HashMap<Long, Long> map = new HashMap<Long, Long>(); //found f at s recently
			HashMap<Long, Long> forend = new HashMap<Long, Long>();

			long sum = 0;
			map.put(0L, -1L);

			for(long i = 0; i < n; i++) {
				sum+=a[(int)i];

				if(map.containsKey(sum)) {
					long x = map.get(sum);
					forend.put(i, x+1);

				}

				map.put(sum, (long)i);

			}

			ArrayList<Long> ends = new ArrayList<Long>();
			for(HashMap.Entry<Long, Long> k: forend.entrySet()) {
				long i = k.getKey();

				ends.add(i);
			}
	        Collections.sort(ends);

	        long ans = 0;
			for(long j = 0; j < n; j++) {

//				long curr = -1;

//				for(long k = j; k < n; k++) {
//
//					if(forend.containsKey(k)) {
//
//						long x = forend.get(k);
//						if(curr == -1) curr = x;
//						else curr = curr < x?curr:x;
//					}
//
//					if(curr == k) {
//						ans+=(k-j);
//						break;
//					}
//
//					if(k == n-1) {
//						ans+=(k-j+1);
//						break;
//					}
//				}

				boolean flag = true;
				for(int k = 0; k < ends.size(); k++) {
					long e = ends.get(k);

					if(e>=j && forend.get(e)>=j) {
						ans+=(e-j);
						flag = false;
						break;
					}

				}

				if(flag) {
					ans+=n-j;
				}

			}

			System.out.println(ans);

		}
	}
}


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

// (int)

public class Codechef  {

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

		Scanner scn = new Scanner(System.in);
//		long t = scn.nextLong();
		long t = 1;
		while(t-->0) {

			long n = scn.nextLong();
//			long m = scn.nextLong();

			long[] a = new long[(int)n];
			for(int i = 0; i < n; i++) {
				a[i] = scn.nextLong();
			}

			HashMap<Long, Long> map = new HashMap<Long, Long>(); //found f at s recently
			HashMap<Long, Long> forend = new HashMap<Long, Long>();
			ArrayList<Long> ends = new ArrayList<Long>();

			long sum = 0;
			map.put(0L, -1L);
			int temp = 0;
			for(long i = 0; i < n; i++) {
				sum+=a[(int)i];

				if(map.containsKey(sum)) {
					long x = map.get(sum);
					forend.put(i, x+1);
					ends.add(i);
				}

				map.put(sum, (long)i);

			}

	        Collections.sort(ends);

	        long ans = 0;
			for(long j = 0; j < n; j++) {

				boolean flag = true;
				for(int k = temp; k < ends.size(); k++) {
					long e = ends.get(k);

					if(e>=j && forend.get(e)>=j) {
						ans+=(e-j);
						if(flag) temp = k;
						flag = false;
						break;
					}

				}

				if(flag) {
					ans+=n-j;
				}

			}

			System.out.println(ans);

		}
	}
}


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

// (int)

public class Codechef  {

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

		Scanner scn = new Scanner(System.in);
//		long t = scn.nextLong();
		long t = 1;
		while(t-->0) {

			long n = scn.nextLong();
//			long m = scn.nextLong();

			long[] a = new long[(int)n];
			for(int i = 0; i < n; i++) {
				a[i] = scn.nextLong();
			}

			HashMap<Long, Long> map = new HashMap<Long, Long>(); //found f at s recently
			HashMap<Long, Long> forend = new HashMap<Long, Long>();
			ArrayList<Long> ends = new ArrayList<Long>();

			long sum = 0;
			map.put(0L, -1L);
			int temp = 0;
			for(long i = 0; i < n; i++) {
				sum+=a[(int)i];

				if(map.containsKey(sum)) {
					long x = map.get(sum);
					forend.put(i, x+1);
					ends.add(i);
				}

				map.put(sum, (long)i);

			}

	        Collections.sort(ends);

	        long ans = 0;
			for(long j = 0; j < n; j++) {

				boolean flag = true;
				for(int k = temp; k < ends.size(); k++) {
					long e = ends.get(k);

					if(e>=j && forend.get(e)>=j) {
						ans+=(e-j);
						flag = false;
						if(flag) temp = k;
						break;
					}

				}

				if(flag) {
					ans+=n-j;
				}

			}

			System.out.println(ans);

		}
	}
}


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

// (int)

public class Codechef  {
//	static class Pair {
//		long i;
//		long j;
//
//		Pair(long i, long j) {
//			this.i = i;
//			this.j = j;
//		}
//
//		Pair(){}
//	}

//	static long factorial(long n)
//    {
//        long res = 1, i;
//        for (i=2; i<=n; i++)
//            res *= i;
//        return res;
//    }

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

		Scanner scn = new Scanner(System.in);
//		long t = scn.nextLong();
		long t = 1;
		while(t-->0) {

			long n = scn.nextLong();
//			long m = scn.nextLong();

			long[] a = new long[(int)n];
			for(int i = 0; i < n; i++) {
				a[i] = scn.nextLong();
			}

			HashMap<Long, Long> map = new HashMap<Long, Long>(); //found f at s recently
//			HashSet<Long> set = new HashSet<Long>();
			HashMap<Long, Long> forend = new HashMap<Long, Long>();
//			ArrayList<Pair> no = new ArrayList<Pair>();

			long sum = 0;
//			set.add(0L);
			map.put(0L, -1L);

			for(long i = 0; i < n; i++) {
				sum+=a[(int)i];

				if(map.containsKey(sum)) {
					long x = map.get(sum);
//					Pair p = new Pair(x+1, i);
					forend.put(x+1, i);

				}

//				set.add(sum);
				map.put(sum, (long)i);

			}

//			HashSet<Long> start = new HashSet<Long>();
//			HashSet<Long> end = new HashSet<Long>();
//			for(int j = 0; j < no.size(); j++) {
//				Pair x = no.get(j);
////				start.add(x.i);
//				forend.put(x.i, x);
//			}

//			Collections.sort(no, new Comparator<Pair>() {
//			    @Override
//			    public int compare(final Pair o1, final Pair o2) {
//			        return (int)(o1.i-o2.i);
//			    }
//			});

//			Iterator<Pair> i = no.iterator();
//	        while (i.hasNext()) {
//	        	Pair p = i.next();
//	            System.out.println(p.i + " " + p.j);
//	        }

	        long ans = 0;
			for(long j = 0; j < n; j++) {
				long curr = -1;
				for(long k = j; k < n; k++) {
					if(forend.containsKey(k)) {
//						end.add(forend.get(k).j);
						long x = forend.get(k);
						if(curr == -1) curr = x;
						else curr = curr < x?curr:x;
					}

					if(curr == k) {
						ans+=(k-j);
						break;
					}
					if(k == n-1) {
						ans+=(k-j+1);
						break;
					}
				}
			}

			System.out.println(ans);

		}
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.Set;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

  static class CYevgeniiIMassiv {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
      int n = in.readInt();
      long[] a = in.readLongArray(n);
      long ans = solve(a);
      out.print(ans);
    }

    long solve(long[] a) {
      int n = a.length;
      long[] b = new long[n + 2];
      for (int i = 1; i <= n; i++) b[i] = b[i - 1] + a[i - 1];
      b[n + 1] = b[n];
      a = b;
      n += 2;
      long res = 0;
      Set<Long> have = new HashSet<>();
      for (int i = 0; i < n; i++) {
        while (have.size() > 1 && have.contains(a[i])) {
          int l = i - have.size();
          int r = i - 1;
          res += r - l;
          have.remove(a[l]);
        }
        have.add(a[i]);
      }
      return res;
    }

  }

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

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

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

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

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

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

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

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

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

    }

  }

  static class OutputWriter {
    private final PrintWriter writer;

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

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

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

    public void print(long i) {
      writer.print(i);
    }

  }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class code {
	public static void main(String[] args)throws IOException {
		FastReader sc = new FastReader();
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		long arr[] = new long[n + 1];
		HashMap<Long, Integer> map = new HashMap<>();
		map.put(0l, 0);
		long sum = 0;
		for (int i = 1; i <= n; i++) {
			arr[i] = sc.nextLong();
		}
		int prev = 0;
		long ans = 0;
		for (int i = 1; i <= n; i++) {
			sum += arr[i];
			if (map.containsKey(sum)) {
				prev = Math.max(prev, map.get(sum) + 1);
			}
			map.put(sum, i);
			//System.out.println(i + " " + prev);
			ans += i - prev;
		}
		System.out.println(ans);

	}
}

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

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

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

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

	String nextLine() {
		String str = "";
		try {
			str = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return str;
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.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);
        CEugeneAndAnArray solver = new CEugeneAndAnArray();
        solver.solve(1, in, out);
        out.close();
    }

    static class CEugeneAndAnArray {
        PrintWriter out;
        InputReader in;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            int n = ni();
            long[] arr = new long[n + 1];
            int i = 0;
            long[] cnt = new long[n + 2];
            HashMap<Long, Integer> hmap = new HashMap<>();
            hmap.put(0L, 0);
            long sum = 0;
            long ans = 0;
            long max = -1;
            for (i = 1; i <= n; i++) {
                arr[i] = nl();
                sum += arr[i];
                if (hmap.containsKey(sum)) {
                    int id = hmap.get(sum);
                    max = Math.max(max, id);
                    ans += (long) (i - max - 1);
                }
                if (!hmap.containsKey(sum))
                    ans += (long) (i - max - 1);
                hmap.put(sum, i);
            }
            pn(ans);
        }

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

        long nl() {
            return in.nextLong();
        }

        void pn(long zx) {
            out.println(zx);
        }

    }

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

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

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

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

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

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

            return res.toString();
        }

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

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.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);
        CEugeneAndAnArray solver = new CEugeneAndAnArray();
        solver.solve(1, in, out);
        out.close();
    }

    static class CEugeneAndAnArray {
        PrintWriter out;
        InputReader in;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            int n = ni();
            long[] arr = new long[n + 1];
            int i = 0;
            long[] cnt = new long[n + 2];
            HashMap<Long, Integer> hmap = new HashMap<>();
            hmap.put(0L, 0);
            long sum = 0;
            long ans = 0;
            long max = -1;
            for (i = 1; i <= n; i++) {
                arr[i] = nl();
                sum += arr[i];
                if (hmap.containsKey(sum)) {
                    int id = hmap.get(sum);
                    max = Math.max(max, id);
                    ans += (long) (i - max - 1);
                }
                if (!hmap.containsKey(sum)) {
                    hmap.put(sum, i);
                    ans += (long) (i - max - 1);
                }
            }
            pn(ans);
        }

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

        long nl() {
            return in.nextLong();
        }

        void pn(long zx) {
            out.println(zx);
        }

    }

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

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

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

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

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

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

            return res.toString();
        }

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

    }
}


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

public class temp {
	static int mod = (int) (1e9 + 7);

	static long findSubarraySum(int arr[], int n, int sum) {
		// HashMap to store number of subarrays
		// starting from index zero having
		// particular value of sum.
		HashMap<Long, Integer> hm = new HashMap<>();
		hm.put( 0L, -1);

		long res = 0;

		// Sum of elements so far.
		long currsum = 0;

		for (int i = 0; i < n; i++) {
			// Add current element to sum so far.
			currsum += arr[i];
			if (hm.containsKey(currsum)){
				res += hm.get(currsum)+2;
			}
			hm.put(currsum,i);
		}

		return res;
	}

	public static void main(String[] args) throws IOException {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scn.nextInt();
		}
		long an = (n * (n + 1)) / 2;
		an = an - findSubarraySum(a, n, 0);
		System.out.println(an);

	}

}


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

public class temp {
	static int mod = (int) (1e9 + 7);

	static long findSubarraySum(int arr[], int n, int sum) {
		// HashMap to store number of subarrays
		// starting from index zero having
		// particular value of sum.
		HashMap<Long, Integer> hm = new HashMap<>();
		hm.put( 0L, -1);

		long res = 0;

		// Sum of elements so far.
		long currsum = 0;

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

			// Add current element to sum so far.
			currsum += arr[i];

			// If currsum is equal to desired sum,
			// then a new subarray is found. So
			// increase count of subarrays.

			// currsum exceeds given sum by currsum
			// - sum. Find number of subarrays having
			// this sum and exclude those subarrays
			// from currsum by increasing count by
			// same amount.
			if (hm.containsKey(currsum)){
				res += hm.get(currsum)+2;
			}
			hm.put(currsum,i);
		}

		return res;
	}

	public static void main(String[] args) throws IOException {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scn.nextInt();
		}
		long an = (n * (n + 1)) / 2;
		an = an - findSubarraySum(a, n, 0);
		System.out.println(an);

	}

}


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

public class temp {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = scn.nextInt();
		}
		HashMap<Long, pair> map = new HashMap<>();

	long sum=arr[0];
	int ans=0;
	map.put((long)0,new pair(-1,-1) );
	map.put((long)arr[0],new pair(0,0));
	int max=0;
	long a=0;
	int previ=0;
	if(arr[0]!=0){
		a+=1;
	}else{
		max=1;
	}
		for (int i = 1; i < n; i++) {
           sum+=arr[i];
           if(map.containsKey(sum)){
        	   pair p=new pair(i,map.get(sum).strt+1);
        	   max=Math.max(max, p.end+1);
        	   map.put(sum, p);
           }
           map.put(sum, new pair(i,0));
         a=a+((long)i-(long)max+1)*((long)i-(long)max+2)/2;

        	if(previ>=max){
        		a-=(((long)previ-(long)max+1)*((long)previ-(long)max+2))/2;
        	}
        	 previ=i;
		}

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

	}

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

	}
	for(int i=0;i<5;i++){

	}
	for(int i=0;i<5;i++){

	}
	System.out.println(a);

	}
	public static class pair{
		int strt;
		int end;
		pair(int strt,int end){
			this.strt=strt;
			this.end=end;

		}
	}

}


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

public class temp {
	static int mod = (int) (1e9 + 7);

	static long findSubarraySum(int arr[], int n, int sum) {
		// HashMap to store number of subarrays
		// starting from index zero having
		// particular value of sum.
		HashMap<Long, Integer> hm = new HashMap<>();
		hm.put( 0L, -1);

		long res = 0;

		// Sum of elements so far.
		long currsum = 0;

		for (int i = 0; i < n; i++) {
			// Add current element to sum so far.
			currsum += arr[i];
			if (hm.containsKey(currsum)){
				res += hm.get(currsum)+2;
			}
			hm.put(currsum,i);
		}

		return res;
	}

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

		long an = ((n * (n + 1))) / 2;
		an = an - findSubarraySum(a, (int) n, 0);
		System.out.println(an);

	}

}


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

public class Solution {
    public static void main(String[] args) throws IOException {
        Reader rd = new Reader();
        int n = rd.nextInt();
        long[] nums = new long[n];
        for(int i = 0; i < n; i++) {
            nums[i] = rd.nextInt();
            if(i != 0) nums[i] += nums[i - 1];
        }

        HashMap<Long, Integer> map = new HashMap<>();
        map.put(0l, -1);
        int ans = 0;
        int l = -1;
        for(int i = 0; i < n; i++) {
            long val = nums[i];
            int get = map.getOrDefault(val, -2);
            if(get < l) ans += i - l;
            else {
                l = get + 1;
                ans += i - l;
            }
            map.put(val, i);
        }
        System.out.println(ans);
    }

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

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

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

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    static class ModMath {
        private static final int DEFAULT_MOD = 1_000_000_007;
        private final long mod;

        public ModMath(long mod, boolean unsafe) {
        /*if (!unsafe && !IntMath.isPrime(mod)) {
            throw new RuntimeException("This class is designed for primes!");
        }*/
            this.mod = mod;
        }

        public ModMath(long mod) {
            this(mod, false);
        }

        public ModMath() {
            this(DEFAULT_MOD, true);
        }

        public long mod(long x) {
            x %= mod;
            return x < 0 ? x + mod : x;
        }

        public long inv(long x) {
            //return pow(x, mod - 2);
            return mod(LongEuclidSolver.solve(x, mod).x);
        }

        public Factorial getFactorial(int n) {
            return new Factorial(this, n);
        }

    }

    static class Factorial {
        private final ModMath mod;
        private final long[] natural;
        private final long[] reverse;

        public Factorial(ModMath mod, int max) {
            this.mod = mod;
            this.natural = new long[max];
            this.reverse = new long[max];
            natural[0] = 1;
            for (int i = 1; i < max; i++) {
                natural[i] = mod.mod(natural[i - 1] * i);
            }
            reverse[max - 1] = mod.inv(natural[max - 1]);
            for (int i = max - 1; i > 0; i--) {
                reverse[i - 1] = mod.mod(reverse[i] * i);
            }
        }

        public long fact(long x) {
            return natural[(int) x];
        }

        public long factinv(long x) {
            return reverse[(int) x];
        }

        public long npr(long n, long r) {
            return n < r ? 0 : mod.mod(fact(n) * factinv(n - r));
        }

        public long ncr(long n, long r) {
            return mod.mod(npr(n, r) * factinv(r));
        }

        public String toString() {
            return "Factorial{" +
                    "natural=" + Arrays.toString(natural) +
                    ", reverse=" + Arrays.toString(reverse) +
                    '}';
        }

    }

    static class LongEuclidSolver {
        private LongEuclidSolver() {
        }

        public static Vec3l solve(long a, long b) {
            LongEuclidSolver.ReferenceLong p = new LongEuclidSolver.ReferenceLong(), q = new LongEuclidSolver.ReferenceLong();
            long d = solve(a, b, p, q);
            return new Vec3l(p.val, q.val, d);
        }

        private static long solve(long a, long b, LongEuclidSolver.ReferenceLong p, LongEuclidSolver.ReferenceLong q) {
            if (b == 0) {
                p.val = 1;
                q.val = 0;
                return a;
            } else {
                long d = solve(b, a % b, q, p);
                q.val -= (a / b) * p.val;
                return d;
            }
        }

        private static class ReferenceLong {
            private long val;

        }

    }

    static class Vec3l implements Comparable<Vec3l> {
        public long x;
        public long y;
        public long z;

        public Vec3l(long x, long y, long z) {
            this.x = x;
            this.y = y;
            this.z = z;
        }

        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Vec3i vec3i = (Vec3i) o;
            return x == vec3i.x &&
                    y == vec3i.y &&
                    z == vec3i.z;
        }

        public int hashCode() {
            return Objects.hash(x, y, z);
        }

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

        public int compareTo(Vec3l o) {
            if (x == o.x) {
                if (y == o.y) {
                    return Long.compare(z, o.z);
                }
                return Long.compare(y, o.z);
            }
            return Long.compare(x, o.x);
        }

    }

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

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

        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Vec3i vec3i = (Vec3i) o;
            return x == vec3i.x &&
                    y == vec3i.y &&
                    z == vec3i.z;
        }

        public int hashCode() {
            return Objects.hash(x, y, z);
        }

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

        public int compareTo(Vec3i o) {
            if (x == o.x) {
                if (y == o.y) {
                    return Integer.compare(z, o.z);
                }
                return Integer.compare(y, o.z);
            }
            return Integer.compare(x, o.x);
        }

    }
}


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

public class Solution {
    public static void main(String[] args) throws IOException {
        Reader rd = new Reader();
        int n = rd.nextInt();
        long[] nums = new long[n];
        for(int i = 0; i < n; i++) {
            nums[i] = rd.nextInt();
            if(i != 0) nums[i] += nums[i - 1];
        }

        HashMap<Long, Integer> map = new HashMap<>();
        map.put(0l, -1);
        long ans = 0;
        int l = -1;
        for(int i = 0; i < n; i++) {
            long val = nums[i];
            int get = map.getOrDefault(val, -2);
            if(get < l) ans += i - l;
            else {
                l = get + 1;
                ans += i - l;
            }
            map.put(val, i);
        }
        System.out.println(ans);
    }

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

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

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

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    static class ModMath {
        private static final int DEFAULT_MOD = 1_000_000_007;
        private final long mod;

        public ModMath(long mod, boolean unsafe) {
        /*if (!unsafe && !IntMath.isPrime(mod)) {
            throw new RuntimeException("This class is designed for primes!");
        }*/
            this.mod = mod;
        }

        public ModMath(long mod) {
            this(mod, false);
        }

        public ModMath() {
            this(DEFAULT_MOD, true);
        }

        public long mod(long x) {
            x %= mod;
            return x < 0 ? x + mod : x;
        }

        public long inv(long x) {
            //return pow(x, mod - 2);
            return mod(LongEuclidSolver.solve(x, mod).x);
        }

        public Factorial getFactorial(int n) {
            return new Factorial(this, n);
        }

    }

    static class Factorial {
        private final ModMath mod;
        private final long[] natural;
        private final long[] reverse;

        public Factorial(ModMath mod, int max) {
            this.mod = mod;
            this.natural = new long[max];
            this.reverse = new long[max];
            natural[0] = 1;
            for (int i = 1; i < max; i++) {
                natural[i] = mod.mod(natural[i - 1] * i);
            }
            reverse[max - 1] = mod.inv(natural[max - 1]);
            for (int i = max - 1; i > 0; i--) {
                reverse[i - 1] = mod.mod(reverse[i] * i);
            }
        }

        public long fact(long x) {
            return natural[(int) x];
        }

        public long factinv(long x) {
            return reverse[(int) x];
        }

        public long npr(long n, long r) {
            return n < r ? 0 : mod.mod(fact(n) * factinv(n - r));
        }

        public long ncr(long n, long r) {
            return mod.mod(npr(n, r) * factinv(r));
        }

        public String toString() {
            return "Factorial{" +
                    "natural=" + Arrays.toString(natural) +
                    ", reverse=" + Arrays.toString(reverse) +
                    '}';
        }

    }

    static class LongEuclidSolver {
        private LongEuclidSolver() {
        }

        public static Vec3l solve(long a, long b) {
            LongEuclidSolver.ReferenceLong p = new LongEuclidSolver.ReferenceLong(), q = new LongEuclidSolver.ReferenceLong();
            long d = solve(a, b, p, q);
            return new Vec3l(p.val, q.val, d);
        }

        private static long solve(long a, long b, LongEuclidSolver.ReferenceLong p, LongEuclidSolver.ReferenceLong q) {
            if (b == 0) {
                p.val = 1;
                q.val = 0;
                return a;
            } else {
                long d = solve(b, a % b, q, p);
                q.val -= (a / b) * p.val;
                return d;
            }
        }

        private static class ReferenceLong {
            private long val;

        }

    }

    static class Vec3l implements Comparable<Vec3l> {
        public long x;
        public long y;
        public long z;

        public Vec3l(long x, long y, long z) {
            this.x = x;
            this.y = y;
            this.z = z;
        }

        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Vec3i vec3i = (Vec3i) o;
            return x == vec3i.x &&
                    y == vec3i.y &&
                    z == vec3i.z;
        }

        public int hashCode() {
            return Objects.hash(x, y, z);
        }

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

        public int compareTo(Vec3l o) {
            if (x == o.x) {
                if (y == o.y) {
                    return Long.compare(z, o.z);
                }
                return Long.compare(y, o.z);
            }
            return Long.compare(x, o.x);
        }

    }

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

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

        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Vec3i vec3i = (Vec3i) o;
            return x == vec3i.x &&
                    y == vec3i.y &&
                    z == vec3i.z;
        }

        public int hashCode() {
            return Objects.hash(x, y, z);
        }

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

        public int compareTo(Vec3i o) {
            if (x == o.x) {
                if (y == o.y) {
                    return Integer.compare(z, o.z);
                }
                return Integer.compare(y, o.z);
            }
            return Integer.compare(x, o.x);
        }

    }
}


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

public class ranjan{

    //public static Read cin;
    public static InputReader cin;
    public static PrintWriter cout;
    public static boolean[][] visited;
    public static boolean[][] visited2;
    public static final long b = (long)1e9+7;
    public static int fileread = 0;

    public static void main(String ...arg) throws IOException
    {
        /*console writer*/
        cout = new PrintWriter(new BufferedOutputStream(System.out));
        /*Debug Reader*/
        //Scan cin =new Scan();
        if(fileread == 1)
        {
            try
            {
            //cin = new Read(new FileInputStream(new File("in2.txt")));
            cin = new InputReader(new FileInputStream(new File("in2.txt")));
            }
            catch (IOException error){}
        }
        else{
            //cin = new Read(System.in);
            cin = new InputReader(System.in);
        }

        int n = cin.nextInt();
        int[] arr = new int[n];
        for(int i=0;i<n;i++) arr[i] = cin.nextInt();
        HashMap<Long,Integer> map = new HashMap<>();
        //keeping 0 index with sum since no number require for sum to zero
        map.put(0L,0);
        long sum = 0,prev = 0,ans = 0;
        for(int i=0;i<n;i++)
        {
            sum += arr[i];
            //taking the maximum of previous considered subarray and current subarray so that i can
            //avoid overlapping of already considered sub array.
            if(map.containsKey(sum))
                prev = Math.max(prev,map.get(sum)+1);
            map.put(sum,i+1);
            ans += i-prev+1;
        }
        cout.print(ans);
        cout.close();
    }

    public static <K, V> V getOrDefault(HashMap<K,V> map, K key, V defaultValue) {
        return map.containsKey(key) ? map.get(key) : defaultValue;
    }

    public static long mod_pow(long x,long n,long mod) {
		long res=1;
		while(n>0) {
			if((n&1)==1)res=res*x%mod;
			x=x*x%mod;
			n>>=1;
		}
		return res;
    }
    public static int gcd(int n1, int n2)
	{
		int r;
		while (n2 != 0)
		{
			r = n1 % n2;
			n1 = n2;
			n2 = r;
		}
		return n1;
	}

	/*public static int lcm(int n1, int n2)
	{
		int answer = (n1 * n2) / (gcd(n1, n2));
		return answer;
	}*/

    static class InputReader {
        final InputStream is;
        final byte[] buf = new byte[1024];
        int pos;
        int size;

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

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

        int read() {
            if (size == -1)
                throw new InputMismatchException();
            if (pos >= size) {
                pos = 0;
                try {
                    size = is.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (size <= 0)
                    return -1;
            }
            return buf[pos++] & 255;
        }

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

    }

static class RecursionLimiter {
    public static long maxLevel = 1549;

    public static void emerge() {
        if (maxLevel == 0)
            return;
        try {
            throw new IllegalStateException("Too deep, emerging");
        } catch (IllegalStateException e) {
            if (e.getStackTrace().length > maxLevel + 1)
                throw e;
        }
    }
}

static class Scan {
        private byte[] buf=new byte[1024];
        private int index;
        private InputStream in;
        private int total;
        public Scan()
        {
            in=System.in;
        }
        public int scan()throws IOException
        {
            if(total<0)
            throw new InputMismatchException();
            if(index>=total)
            {
                index=0;
                total=in.read(buf);
                if(total<=0)
                return -1;
            }
            return buf[index++];
        }
        public int scanInt()throws IOException
        {
            int integer=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    integer*=10;
                    integer+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            return neg*integer;
        }
        public double scanDouble()throws IOException
        {
            double doub=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n)&&n!='.')
            {
                if(n>='0'&&n<='9')
                {
                    doub*=10;
                    doub+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            if(n=='.')
            {
                n=scan();
                double temp=1;
                while(!isWhiteSpace(n))
                {
                    if(n>='0'&&n<='9')
                    {
                        temp/=10;
                        doub+=(n-'0')*temp;
                        n=scan();
                    }
                    else throw new InputMismatchException();
                }
            }
            return doub*neg;
        }
        public String scanString()throws IOException
        {
            StringBuilder sb=new StringBuilder();
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            while(!isWhiteSpace(n))
            {
                sb.append((char)n);
                n=scan();
            }
            return sb.toString();
        }
        private boolean isWhiteSpace(int n)
        {
            if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
            return true;
            return false;
        }
    }

}

class Read
{
    private BufferedReader br;
    private StringTokenizer st;

    public Read(InputStream is)
    { br = new BufferedReader(new InputStreamReader(is)); }

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

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

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

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

    String nextLine()
    {
        String str = "";
        try {str = br.readLine();}
        catch(IOException e)
            {e.printStackTrace();}
        return str;
    }
}


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

public class ranjan{

    //public static Read cin;
    public static InputReader cin;
    public static PrintWriter cout;
    public static boolean[][] visited;
    public static boolean[][] visited2;
    public static final long b = (long)1e9+7;
    public static int fileread = 1;

    public static void main(String ...arg) throws IOException
    {
        /*console writer*/
        cout = new PrintWriter(new BufferedOutputStream(System.out));
        /*Debug Reader*/
        //Scan cin =new Scan();
        if(fileread == 1)
        {
            try
            {
            //cin = new Read(new FileInputStream(new File("in2.txt")));
            cin = new InputReader(new FileInputStream(new File("in2.txt")));
            }
            catch (IOException error){}
        }
        else{
            //cin = new Read(System.in);
            cin = new InputReader(System.in);
        }

        int n = cin.nextInt();
        int[] arr = new int[n];
        for(int i=0;i<n;i++) arr[i] = cin.nextInt();
        HashMap<Long,Integer> map = new HashMap<>();
        //keeping 0 index with sum since no number require for sum to zero
        map.put(0L,0);
        long sum = 0,prev = 0,ans = 0;
        for(int i=0;i<n;i++)
        {
            sum += arr[i];
            //taking the maximum of previous considered subarray and current subarray so that i can
            //avoid overlapping of already considered sub array.
            if(map.containsKey(sum))
                prev = Math.max(prev,map.get(sum)+1);
            map.put(sum,i+1);
            ans += i-prev+1;
        }
        cout.print(ans);
        cout.close();
    }

    public static <K, V> V getOrDefault(HashMap<K,V> map, K key, V defaultValue) {
        return map.containsKey(key) ? map.get(key) : defaultValue;
    }

    public static long mod_pow(long x,long n,long mod) {
		long res=1;
		while(n>0) {
			if((n&1)==1)res=res*x%mod;
			x=x*x%mod;
			n>>=1;
		}
		return res;
    }
    public static int gcd(int n1, int n2)
	{
		int r;
		while (n2 != 0)
		{
			r = n1 % n2;
			n1 = n2;
			n2 = r;
		}
		return n1;
	}

	/*public static int lcm(int n1, int n2)
	{
		int answer = (n1 * n2) / (gcd(n1, n2));
		return answer;
	}*/

    static class InputReader {
        final InputStream is;
        final byte[] buf = new byte[1024];
        int pos;
        int size;

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

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

        int read() {
            if (size == -1)
                throw new InputMismatchException();
            if (pos >= size) {
                pos = 0;
                try {
                    size = is.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (size <= 0)
                    return -1;
            }
            return buf[pos++] & 255;
        }

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

    }

static class RecursionLimiter {
    public static long maxLevel = 1549;

    public static void emerge() {
        if (maxLevel == 0)
            return;
        try {
            throw new IllegalStateException("Too deep, emerging");
        } catch (IllegalStateException e) {
            if (e.getStackTrace().length > maxLevel + 1)
                throw e;
        }
    }
}

static class Scan {
        private byte[] buf=new byte[1024];
        private int index;
        private InputStream in;
        private int total;
        public Scan()
        {
            in=System.in;
        }
        public int scan()throws IOException
        {
            if(total<0)
            throw new InputMismatchException();
            if(index>=total)
            {
                index=0;
                total=in.read(buf);
                if(total<=0)
                return -1;
            }
            return buf[index++];
        }
        public int scanInt()throws IOException
        {
            int integer=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    integer*=10;
                    integer+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            return neg*integer;
        }
        public double scanDouble()throws IOException
        {
            double doub=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n)&&n!='.')
            {
                if(n>='0'&&n<='9')
                {
                    doub*=10;
                    doub+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            if(n=='.')
            {
                n=scan();
                double temp=1;
                while(!isWhiteSpace(n))
                {
                    if(n>='0'&&n<='9')
                    {
                        temp/=10;
                        doub+=(n-'0')*temp;
                        n=scan();
                    }
                    else throw new InputMismatchException();
                }
            }
            return doub*neg;
        }
        public String scanString()throws IOException
        {
            StringBuilder sb=new StringBuilder();
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            while(!isWhiteSpace(n))
            {
                sb.append((char)n);
                n=scan();
            }
            return sb.toString();
        }
        private boolean isWhiteSpace(int n)
        {
            if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
            return true;
            return false;
        }
    }

}

class Read
{
    private BufferedReader br;
    private StringTokenizer st;

    public Read(InputStream is)
    { br = new BufferedReader(new InputStreamReader(is)); }

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

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

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

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

    String nextLine()
    {
        String str = "";
        try {str = br.readLine();}
        catch(IOException e)
            {e.printStackTrace();}
        return str;
    }
}


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

public class C {

    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        Map<Long, Integer> set = new HashMap<>();
        int n = in.nextInt();
        long sum = 0;
        long ans = 0;
        int pos = 0;
        set.put(sum, 0);
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            sum += a;
            if (!set.containsKey(sum)) {
                set.put(sum, i + 1);
            }
            int repetedBefore = set.get(sum);
            if (repetedBefore == i + 1) repetedBefore = pos - 1;
            pos = Math.max(pos, repetedBefore + 1);
            ans += i + 1 - pos;
            set.put(sum, i + 1);
        }
        System.out.println(ans);
    }
}


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

public class C {

    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        Map<Integer, Integer> set = new HashMap<>();
        int n = in.nextInt();
        int sum = 0;
        long ans = 0;
        int pos = 0;
        set.put(sum, 0);
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            sum += a;
            if (!set.containsKey(sum)) {
                set.put(sum, i + 1);
            }
            int repetedBefore = set.get(sum);
            if (repetedBefore == i + 1) repetedBefore = pos - 1;
            pos = Math.max(pos, repetedBefore + 1);
            ans += i + 1 - pos;
            set.put(sum, i + 1);
        }
        System.out.println(ans);
    }
}


import java.io.*;
import java.util.*;
import java.lang.*;
public class Codechef {
	PrintWriter out;
    StringTokenizer st;
    BufferedReader br;

 	class Pair implements Comparable<Pair>
	{
	    int f;
	    int s;

	    Pair(int t, int r) {
	       f = t;
	       s = r;
	    }
	    public int compareTo(Pair p)
	    {
	    	if(this.f!=p.f)
	    		return this.f-p.f;

	    	return this.s-p.s;
	    }
 	}
 // 	class Sort implements Comparator<Integer>
	// {
	//     public int compare(Integer a, Integer b)
	//     {
	//     	if(a<0)
	//     		a*=-1;
	//     	if(b<0)
	//     		b*=-1;
	//         return a.compareTo(b);
	//     }
	// }

	String ns() {
        while (st == null || !st.hasMoreElements()) {

            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    String nextLine() throws Exception {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            throw new Exception(e.toString());
        }
        return str;
    }

    int nextInt() {
        return Integer.parseInt(ns());
    }

    long nextLong() {
        return Long.parseLong(ns());
    }

    double nextDouble() {
        return Double.parseDouble(ns());
    }

	int upperBound(ArrayList<Integer> a,int key,int n) //on sorted array
	{
		int l=0,r=a.size()-1;
		int i=n;

		while(l<=r)
		{
			int mid=(l+r)/2;
			if(a.get(mid)<=key)
				l=mid+1;
			else
			{
				i=a.get(mid);
				r=mid-1;
			}
		}
	//	out.println(key+" hey"+ind);
		return i;
	}

	void solve() throws IOException{
		int n=nextInt();
		int a[]=new int[n];
		long p[]= new long[n+1];
		HashMap<Long,Integer> map = new HashMap<>();
		for(int i=0;i<n;i++){
			a[i]=nextInt();
			p[i+1]=a[i]+p[i];
		}
		int min=0;
		long ans=0;
		for(int i=n;i>-1;i--)
		{
			int t=n-i;
			if(map.containsKey(p[i])){
				t=map.get(p[i])-i-1;
				t=Math.min(min,t);
				min=t;
			}
			else{
				map.put(p[i],i);

			}
			ans+=t;
			min++;
		}
		out.println(ans);
	}

    void run() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
		solve();
		out.flush();
		out.close();
	}

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

}


import java.io.*;
import java.util.*;
import java.lang.*;
public class Codechef {
	PrintWriter out;
    StringTokenizer st;
    BufferedReader br;

 	class Pair implements Comparable<Pair>
	{
	    int f;
	    int s;

	    Pair(int t, int r) {
	       f = t;
	       s = r;
	    }
	    public int compareTo(Pair p)
	    {
	    	if(this.f!=p.f)
	    		return this.f-p.f;

	    	return this.s-p.s;
	    }
 	}
 // 	class Sort implements Comparator<Integer>
	// {
	//     public int compare(Integer a, Integer b)
	//     {
	//     	if(a<0)
	//     		a*=-1;
	//     	if(b<0)
	//     		b*=-1;
	//         return a.compareTo(b);
	//     }
	// }

	String ns() {
        while (st == null || !st.hasMoreElements()) {

            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    String nextLine() throws Exception {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            throw new Exception(e.toString());
        }
        return str;
    }

    int nextInt() {
        return Integer.parseInt(ns());
    }

    long nextLong() {
        return Long.parseLong(ns());
    }

    double nextDouble() {
        return Double.parseDouble(ns());
    }

	int upperBound(ArrayList<Integer> a,int key,int n) //on sorted array
	{
		int l=0,r=a.size()-1;
		int i=n;

		while(l<=r)
		{
			int mid=(l+r)/2;
			if(a.get(mid)<=key)
				l=mid+1;
			else
			{
				i=a.get(mid);
				r=mid-1;
			}
		}
	//	out.println(key+" hey"+ind);
		return i;
	}

	void solve() throws IOException{
		int n=nextInt();
		int a[]=new int[n];
		long p[]= new long[n+1];
		HashMap<Long,Integer> map = new HashMap<>();
		for(int i=0;i<n;i++){
			a[i]=nextInt();
			p[i+1]=a[i]+p[i];
		}
		int min=0;
		long ans=0;
		for(int i=n;i>-1;i--)
		{
			int t=n-i;
			if(map.containsKey(p[i])){
				t=map.get(p[i])-i-1;
			}

			min=Math.min(min,t);
			t=min;
			ans+=t;
			min++;
			map.put(p[i],i);
		}
		out.println(ans);
	}

    void run() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
		solve();
		out.flush();
		out.close();
	}

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

}


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

public class c implements Runnable {
	boolean multiple = false; // for multiple test cases
	long MOD = 998244353;

	@SuppressWarnings("Duplicates")
	void solve() throws Exception {
		int n = sc.nextInt();
		int[] ar = new int [n];
		for(int i = 0 ; i < n ; i++)
			ar[i] = sc.nextInt();
		long sum = 0 ;
		HashMap<Long , Integer> map = new HashMap<>();
		map.put(0L , 0);
		long ans  = 0 ;
		int max = -1;
	  for(int i =  0 ; i < n ;i++) {

		  sum = sum + (long)ar[i];
		  long temp = i+1;
		  if(map.containsKey(sum)) {
			 max = Math.max(max ,  map.get(sum) );
		  }
		   temp  = i - max;

		  map.put(sum ,i+1 );
	 // System.out.println(temp);
		  ans += temp ;
	  }
		  System.out.println(ans);

	}

	class Node implements Comparable<Node> {
		int k, pos, idx;

		Node(int K, int P, int I) {
			k = K;
			pos = P;
			idx = I;
		}

		@Override
		public int compareTo(Node o) {
			return Integer.compare(k, o.k);
		}
	}

	long powmod(long x, long y) {
		if (y == 0)
			return 1L;
		long t = powmod(x, y / 2);
		if (y % 2 == 0)
			return (t * t) % MOD;
		return (((x * t) % MOD) * t) % MOD;
	}

	long inv(long a, long b) {
		return 1 < a ? b - inv(b % a, a) * b / a : 1;
	}

	TreeMap<Integer, TreeSet<Integer>> buildGraph(int n, int m) throws Exception {
		TreeMap<Integer, TreeSet<Integer>> graph = new TreeMap<>();
		for (int i = 1; i <= n; i++)
			graph.put(i, new TreeSet<>());
		for (int i = 0; i < m; i++) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			graph.get(u).add(v);
			graph.get(v).add(u);
		}
		return graph;
	}

	TreeMap<Integer, TreeSet<Integer>> buildDirGraph(int n, int m) throws Exception {
		TreeMap<Integer, TreeSet<Integer>> graph = new TreeMap<>();
		for (int i = 1; i <= n; i++)
			graph.put(i, new TreeSet<>());
		for (int i = 0; i < m; i++)
			graph.get(sc.nextInt()).add(sc.nextInt());
		return graph;
	}

	TreeMap<Integer, TreeSet<Integer>> revGraph(TreeMap<Integer, TreeSet<Integer>> graph) {
		TreeMap<Integer, TreeSet<Integer>> rev = new TreeMap<>();
		for (Integer u : graph.keySet())
			rev.put(u, new TreeSet<>());
		for (Integer u : graph.keySet())
			for (Integer v : graph.get(u))
				rev.get(v).add(u);
		return rev;
	}

	TreeMap<Long, Integer> counts(long[] arr) {
		TreeMap<Long, Integer> counts = new TreeMap<>();
		for (long a : arr) {
			if (!counts.containsKey(a))
				counts.put(a, 0);
			counts.put(a, counts.get(a) + 1);
		}
		return counts;
	}

	String reverse(String s, int i, int j) /* [i, j] closed */ {
		return (i > j) ? reverse(s, j, i)
				: s.substring(0, i) + (new StringBuilder(s.substring(i, j + 1))).reverse()
						+ ((j + 1 <= s.length() - 1) ? s.substring(j + 1) : "");
	}

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			if (multiple) {
				int q = sc.nextInt();
				for (int i = 0; i < q; i++)
					solve();
			} else
				solve();
		} catch (Throwable uncaught) {
			c.uncaught = uncaught;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread thread = new Thread(null, new c(), "", (1 << 26));
		thread.start();
		thread.join();
		if (c.uncaught != null) {
			throw c.uncaught;
		}
	}

	static Throwable uncaught;
	BufferedReader in;
	FastScanner sc;
	PrintWriter out;
}

class FastScanner {
	BufferedReader in;
	StringTokenizer st;

	public FastScanner(BufferedReader in) {
		this.in = in;
	}

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

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

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

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


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

public class c implements Runnable {
	boolean multiple = false; // for multiple test cases
	long MOD = 998244353;

	@SuppressWarnings("Duplicates")
	void solve() throws Exception {
		int n = sc.nextInt();
		int[] ar = new int [n];
		for(int i = 0 ; i < n ; i++)
			ar[i] = sc.nextInt();
		long sum = 0 ;
		HashMap<Long , Integer> map = new HashMap<>();
		map.put(0L , 0);
		long ans  = 0 ;
	  for(int i =  0 ; i < n ;i++) {

		  sum = sum + (long)ar[i];
		  long temp = i+1;
		  if(map.containsKey(sum)) {
		   temp  = i - map.get(sum);
		  }

		  map.put(sum ,i+1 );
	//  System.out.println(temp);
		  ans += temp ;
	  }
		  System.out.println(ans);

	}

	class Node implements Comparable<Node> {
		int k, pos, idx;

		Node(int K, int P, int I) {
			k = K;
			pos = P;
			idx = I;
		}

		@Override
		public int compareTo(Node o) {
			return Integer.compare(k, o.k);
		}
	}

	long powmod(long x, long y) {
		if (y == 0)
			return 1L;
		long t = powmod(x, y / 2);
		if (y % 2 == 0)
			return (t * t) % MOD;
		return (((x * t) % MOD) * t) % MOD;
	}

	long inv(long a, long b) {
		return 1 < a ? b - inv(b % a, a) * b / a : 1;
	}

	TreeMap<Integer, TreeSet<Integer>> buildGraph(int n, int m) throws Exception {
		TreeMap<Integer, TreeSet<Integer>> graph = new TreeMap<>();
		for (int i = 1; i <= n; i++)
			graph.put(i, new TreeSet<>());
		for (int i = 0; i < m; i++) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			graph.get(u).add(v);
			graph.get(v).add(u);
		}
		return graph;
	}

	TreeMap<Integer, TreeSet<Integer>> buildDirGraph(int n, int m) throws Exception {
		TreeMap<Integer, TreeSet<Integer>> graph = new TreeMap<>();
		for (int i = 1; i <= n; i++)
			graph.put(i, new TreeSet<>());
		for (int i = 0; i < m; i++)
			graph.get(sc.nextInt()).add(sc.nextInt());
		return graph;
	}

	TreeMap<Integer, TreeSet<Integer>> revGraph(TreeMap<Integer, TreeSet<Integer>> graph) {
		TreeMap<Integer, TreeSet<Integer>> rev = new TreeMap<>();
		for (Integer u : graph.keySet())
			rev.put(u, new TreeSet<>());
		for (Integer u : graph.keySet())
			for (Integer v : graph.get(u))
				rev.get(v).add(u);
		return rev;
	}

	TreeMap<Long, Integer> counts(long[] arr) {
		TreeMap<Long, Integer> counts = new TreeMap<>();
		for (long a : arr) {
			if (!counts.containsKey(a))
				counts.put(a, 0);
			counts.put(a, counts.get(a) + 1);
		}
		return counts;
	}

	String reverse(String s, int i, int j) /* [i, j] closed */ {
		return (i > j) ? reverse(s, j, i)
				: s.substring(0, i) + (new StringBuilder(s.substring(i, j + 1))).reverse()
						+ ((j + 1 <= s.length() - 1) ? s.substring(j + 1) : "");
	}

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			if (multiple) {
				int q = sc.nextInt();
				for (int i = 0; i < q; i++)
					solve();
			} else
				solve();
		} catch (Throwable uncaught) {
			c.uncaught = uncaught;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread thread = new Thread(null, new c(), "", (1 << 26));
		thread.start();
		thread.join();
		if (c.uncaught != null) {
			throw c.uncaught;
		}
	}

	static Throwable uncaught;
	BufferedReader in;
	FastScanner sc;
	PrintWriter out;
}

class FastScanner {
	BufferedReader in;
	StringTokenizer st;

	public FastScanner(BufferedReader in) {
		this.in = in;
	}

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

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

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

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


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

public class c implements Runnable {
	boolean multiple = false; // for multiple test cases
	long MOD = 998244353;

	@SuppressWarnings("Duplicates")
	void solve() throws Exception {
		int n = sc.nextInt();
		int[] ar = new int [n];
		for(int i = 0 ; i < n ; i++)
			ar[i] = sc.nextInt();
		long sum = 0 ;
		HashMap<Long , Long> map = new HashMap<>();
		map.put(0L , 0L);
		long ans  = 0 ;
	  for(int i =  0 ; i < n ;i++) {

		  sum = sum + ar[i];
		  long temp = i+1;
		  if(map.containsKey(sum)) {
		   temp  = i - map.get(sum);
		  }

		  map.put(sum ,(long)i+1 );
	//  System.out.println(temp);
		  ans += temp ;
	  }
		  System.out.println(ans);

	}

	class Node implements Comparable<Node> {
		int k, pos, idx;

		Node(int K, int P, int I) {
			k = K;
			pos = P;
			idx = I;
		}

		@Override
		public int compareTo(Node o) {
			return Integer.compare(k, o.k);
		}
	}

	long powmod(long x, long y) {
		if (y == 0)
			return 1L;
		long t = powmod(x, y / 2);
		if (y % 2 == 0)
			return (t * t) % MOD;
		return (((x * t) % MOD) * t) % MOD;
	}

	long inv(long a, long b) {
		return 1 < a ? b - inv(b % a, a) * b / a : 1;
	}

	TreeMap<Integer, TreeSet<Integer>> buildGraph(int n, int m) throws Exception {
		TreeMap<Integer, TreeSet<Integer>> graph = new TreeMap<>();
		for (int i = 1; i <= n; i++)
			graph.put(i, new TreeSet<>());
		for (int i = 0; i < m; i++) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			graph.get(u).add(v);
			graph.get(v).add(u);
		}
		return graph;
	}

	TreeMap<Integer, TreeSet<Integer>> buildDirGraph(int n, int m) throws Exception {
		TreeMap<Integer, TreeSet<Integer>> graph = new TreeMap<>();
		for (int i = 1; i <= n; i++)
			graph.put(i, new TreeSet<>());
		for (int i = 0; i < m; i++)
			graph.get(sc.nextInt()).add(sc.nextInt());
		return graph;
	}

	TreeMap<Integer, TreeSet<Integer>> revGraph(TreeMap<Integer, TreeSet<Integer>> graph) {
		TreeMap<Integer, TreeSet<Integer>> rev = new TreeMap<>();
		for (Integer u : graph.keySet())
			rev.put(u, new TreeSet<>());
		for (Integer u : graph.keySet())
			for (Integer v : graph.get(u))
				rev.get(v).add(u);
		return rev;
	}

	TreeMap<Long, Integer> counts(long[] arr) {
		TreeMap<Long, Integer> counts = new TreeMap<>();
		for (long a : arr) {
			if (!counts.containsKey(a))
				counts.put(a, 0);
			counts.put(a, counts.get(a) + 1);
		}
		return counts;
	}

	String reverse(String s, int i, int j) /* [i, j] closed */ {
		return (i > j) ? reverse(s, j, i)
				: s.substring(0, i) + (new StringBuilder(s.substring(i, j + 1))).reverse()
						+ ((j + 1 <= s.length() - 1) ? s.substring(j + 1) : "");
	}

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			if (multiple) {
				int q = sc.nextInt();
				for (int i = 0; i < q; i++)
					solve();
			} else
				solve();
		} catch (Throwable uncaught) {
			c.uncaught = uncaught;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread thread = new Thread(null, new c(), "", (1 << 26));
		thread.start();
		thread.join();
		if (c.uncaught != null) {
			throw c.uncaught;
		}
	}

	static Throwable uncaught;
	BufferedReader in;
	FastScanner sc;
	PrintWriter out;
}

class FastScanner {
	BufferedReader in;
	StringTokenizer st;

	public FastScanner(BufferedReader in) {
		this.in = in;
	}

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

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

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

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


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	static ArrayList<Edge> adj[];
	static PrintWriter out = new PrintWriter(System.out);
	public static long mod;

	static int [][]notmemo;
	static int k;
	static int a[];
	static int b[];
	static int m;
	static char c[];

	static class Pair implements Comparable<Pair>{
    	int x;
    	int y;
    	public Pair(int a,int b) {
		x=a;
		y=b;

    	}
		@Override
		public int compareTo(Pair o) {
			if(x!=o.x)
			return x-o.x;
			return y-o.y;
		}

    }
    static Pair s1[];
    static int s[];
    static ArrayList<Pair> adjlist[];
	private static HashSet<Integer> set1[];
	public static void main(String args[]) throws IOException {
		Scanner sc = new Scanner(System.in);
	int n=sc.nextInt();
	long a[]=new long[n];
	for (int i = 0; i < a.length; i++) {
		a[i]=sc.nextInt();
	}

	HashMap<Long,Integer> map=new HashMap<>();
	long cursum=0;
	int start=0;
	long count=0;
	for (int i = 0; i < a.length; i++) {
		if(map.containsKey(cursum+a[i])) {
			int idx=map.get(cursum+a[i]);
			map.clear();
			//map.put(0*1l,0);
			cursum=0;
			long len=i-start;
			if(len==0) {
				len=1;
			}
			long len2=i-idx-1;

	//		System.out.println("hi"+" "+i+" "+start+" "+idx);
			count+=(((len)*(len+1))/2);
		//	System.out.println(count);
			count-=(((len2)*(len2+1))/2);
			//System.out.println(count);
			start=idx+1;
		i=idx;
		}
		else if(cursum+a[i]==0) {
			//System.out.println(i+" "+start);
			count+=i-start;
			start++;
			i=start-1;
			//System.out.println(i+" "+start);

			map.clear();
			cursum=0;
		}
		else {
			cursum+=a[i];
			map.put(cursum,i+1);
		}
	}
//	System.out.println(start+" "+count);
	long len=n-start;
//	System.out.println(len+" h"+" "+count);
	count+=(((len)*(len+1))/2);

	System.out.println(count);
	}
    // with sum exactly equal to k.
    static int findSubarraySum(int arr[], int n, int sum)
    {
        // HashMap to store number of subarrays
        // starting from index zero having
        // particular value of sum.
        HashMap <Integer, Integer> prevSum = new HashMap<>();

        int res = 0;

        // Sum of elements so far.
        int currsum = 0;

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

            // Add current element to sum so far.
            currsum += arr[i];

            // If currsum is equal to desired sum,
            // then a new subarray is found. So
            // increase count of subarrays.
            if (currsum != 0)
                res++;

            // currsum exceeds given sum by currsum
            //  - sum. Find number of subarrays having
            // this sum and exclude those subarrays
            // from currsum by increasing count by
            // same amount.
            if (prevSum.containsKey(currsum - arr[i]))
                res += prevSum.get(currsum - arr[i]);

            // Add currsum value to count of
            // different values of sum.
            Integer count = prevSum.get(currsum);
            if (count == null)
                prevSum.put(currsum, 1);
            else
                prevSum.put(currsum, count+1);
        }

        return res;
    }
	public static int countvowels() {
		int count=0;
		for (int i = 0; i < c.length; i++) {
			if(c[i]=='o'||c[i]=='e'||c[i]=='a'||c[i]=='i'||c[i]=='u') {
				count++;
			}
		}
		return count;
	}
	public static  char lastvowel() {
		for (int i = c.length-1; i>=0; i--) {
			if(c[i]=='o'||c[i]=='e'||c[i]=='a'||c[i]=='i'||c[i]=='u') {
		return c[i];
			}
		}
		return 'a';
	}
	static class pp{
		String ss;
		String mm;
		public pp(String a,String b) {
		ss=a;
		mm=b;
		}
	}
	static class Tri implements Comparable<Tri>{
		String s;
		int numofvow;
		char lastchar;
	public	Tri(String m,int a,char c1){
			s=m;
			numofvow=a;
			lastchar=c1;

		}
	public int compareTo(Tri t) {
		if (numofvow == t.numofvow)
			return lastchar - t.lastchar;
		return numofvow - t.numofvow;
	}

	}
	static boolean dfs(int u, int cost) {
		boolean f=false;
		vis[u]=true;
		for(Edge p:adj[u]) {
			if(!vis[p.node]) {
				f|=dfs(p.node,(int) p.cost);
			}
		}
		if (cost == 2&&!f) {
				set.add(u + 1);
				return true;
		}
			return f;

	}
	static int min(int i,int last) {
		if(i==a.length)
			return 0;
		int take=0;
		if(gcd(a[i],last)>1||i==0) {
			take=Math.max(take,1+min(i+1,a[i]));
		}
	 take=Math.max(take,min(i+1,last));

		return b[i]=take;
	}

	private static boolean check(String s) {
		char c1[]=s.toCharArray();
		for (int i = 0; i < c1.length; i++) {
			if(c[i]>c1[i]) {
				return true;
			}
			 if(c[i]<c1[i])
				return false;
		}
		return true;
	}

	static long dijkstra(int S, int T)	//O(E log E)
	{
		long[] dist = new long[V];
		Arrays.fill(dist, (int) 1e9);
		PriorityQueue<Edge> pq = new PriorityQueue<Edge>();
		dist[S] = 0;
		pq.add(new Edge(S, 0));						//may add more in case of MSSP (Mult-Source)
		while(!pq.isEmpty())
		{
			Edge cur = pq.remove();
			if(cur.node == T)						//remove if all computations are needed
				return dist[T];
			if(cur.cost > dist[cur.node])			//lazy deletion
				continue;
			for(Edge nxt: adj[cur.node])
				if(cur.cost + nxt.cost < dist[nxt.node])
					pq.add(new Edge(nxt.node, dist[nxt.node] = cur.cost + nxt.cost ));
		}
		return -1;
	}
	static class Edge implements Comparable<Edge>
	{
		int node;long cost;

		Edge(int a, long b) { node = a;	cost = b; }

		public int compareTo(Edge e){ return Long.compare(cost,e.cost);	}
	}

    static int dp(int idx,int state) {
      if(idx==n) {
    	  return 0;
      }
      if(notmemo[idx][state]!=-1) {
    	  return notmemo[idx][state];
      }
     int take=0; int leave=0;int leaveall=0;
      if(a[idx]==1&&(state==1||state==0)) {
    	take=1+dp(idx+1,1);
      }
      if(a[idx]==0&&state==0) {
    	 leave=1+dp(idx+1,state);
      }
      leaveall=dp(idx+1,state);

      return notmemo[idx][state]=Math.max(take,Math.max(leaveall,leave));
    }
        static void sieve(int N)	// O(N log log N)
	{
		isComposite = new int[N+1];
		isComposite[0] = isComposite[1] = 1;			// 0 indicates a prime number
		primes = new ArrayList<Integer>();

		for (int i = 2; i <= N; ++i) 					//can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
			if (isComposite[i] == 0) 					//can loop in 2 and odd integers for slightly better performance
			{
				primes.add(i);
				if(1l * i * i <= N)
					for (int j = i * i; j <= N; j += i)	// j = i * 2 will not affect performance too much, may alter in modified sieve
						isComposite[j] = 1;
			}
	}
    static TreeSet<Integer> factors;
    static ArrayList<Integer> primeFactors(int N)		// O(sqrt(N) / ln sqrt(N))
	{
		ArrayList<Integer> factors = new ArrayList<Integer>();		//take abs(N) in case of -ve integers
		int idx = 0, p = primes.get(idx);

		while(1l*p * p <= N)
		{
			while(N % p == 0) { factors.add(p); N /= p; }
			p = primes.get(++idx);
		}

		if(N != 1)						// last prime factor may be > sqrt(N)
			factors.add(N);				// for integers whose largest prime factor has a power of 1
		return factors;
	}

    static String y;
    	static int nomnom[];
	static long fac[];

	static class book implements Comparable<book> {
		int idx;
		long score;

		public book(int i, long s) {
			idx = i;
			score = s;
		}

		public int compareTo(book o) {
			return (int) (o.score - score);
		}
	}

	static class library implements Comparable<library> {
		int numofbooks;
		int signup;
		int shiprate;
		int idx;

		public library(int a, int b, int c, int idx) {
			numofbooks = a;
			signup = b;
			shiprate = c;
			this.idx = idx;
		}

		@Override
		public int compareTo(library o) {
		if(signup==o.signup) {
			  return o.numofbooks-numofbooks;
		}
		return signup - o.signup;

		}
	}

	static boolean isOn(int S, int j) {
		return (S & 1 << j) != 0;
	}

	static boolean f = true;

	static class SegmentTree { // 1-based DS, OOP

		int N; // the number of elements in the array as a power of 2 (i.e. after padding)
		int[] array, sTree, lazy;

		SegmentTree(int[] in) {
			array = in;
			N = in.length - 1;
			sTree = new int[N << 1]; // no. of nodes = 2*N - 1, we add one to cross out index zero
			lazy = new int[N << 1];
			//build(1, 1, N);
		}

		void build(int node, int b, int e) // O(n)
		{
			if (b == e)
				sTree[node] = array[b];
			else {
				int mid = b + e >> 1;
				build(node << 1, b, mid);
				build(node << 1 | 1, mid + 1, e);
				sTree[node] = sTree[node << 1] + sTree[node << 1 | 1];
			}
		}

		void update_point(int index, int val) // O(log n)
		{
			index += N - 1;
			sTree[index] = val;
			while(index>1)
			{
				index >>= 1;
				sTree[index] = Math.max(sTree[index<<1] ,sTree[index<<1|1]);
			}
		}

		void update_range(int i, int j, int val) // O(log n)
		{
			update_range(1, 1, N, i, j, val);
		}

		void update_range(int node, int b, int e, int i, int j, int val) {
			if (i > e || j < b)
				return;
			if (b >= i && e <= j) {
				sTree[node] += (e - b + 1) * val;
				lazy[node] += val;
			} else {
				int mid = b + e >> 1;
				propagate(node, b, mid, e);
				update_range(node << 1, b, mid, i, j, val);
				update_range(node << 1 | 1, mid + 1, e, i, j, val);
				sTree[node] = sTree[node << 1] + sTree[node << 1 | 1];
			}

		}

		void propagate(int node, int b, int mid, int e) {
			lazy[node << 1] += lazy[node];
			lazy[node << 1 | 1] += lazy[node];
			sTree[node << 1] += (mid - b + 1) * lazy[node];
			sTree[node << 1 | 1] += (e - mid) * lazy[node];
			lazy[node] = 0;
		}

		int query(int i, int j) {
			return query(1, 1, N, i, j);
		}

		int query(int node, int b, int e, int i, int j) // O(log n)
		{
			if (i > e || j < b)
				return 0;
			if (b >= i && e <= j)
				return sTree[node];
			int mid = b + e >> 1;
			// propagate(node, b, mid, e);
			int q1 = query(node << 1, b, mid, i, j);
			int q2 = query(node << 1 | 1, mid + 1, e, i, j);
			return Math.max(q1,q2);

		}
	}

	static int memo[];

	static class UnionFind {
		int[] p, rank, setSize;
		int numSets;
		int max[];

		public UnionFind(int N) {
			p = new int[numSets = N];
			rank = new int[N];
			setSize = new int[N];
			for (int i = 0; i < N; i++) {
				p[i] = i;
				setSize[i] = 1;
			}
		}

		public int findSet(int i) {
			return p[i] == i ? i : (p[i] = findSet(p[i]));
		}

		public boolean isSameSet(int i, int j) {
			return findSet(i) == findSet(j);
		}

		public void unionSet(int i, int j) {
			if (isSameSet(i, j))
				return;
			numSets--;
			int x = findSet(i), y = findSet(j);
			if (rank[x] > rank[y]) {
				p[y] = x;
				setSize[x] += setSize[y];

			} else {
				p[x] = y;
				setSize[y] += setSize[x];
				if (rank[x] == rank[y])
					rank[y]++;

			}
		}

		public int numDisjointSets() {
			return numSets;
		}

		public int sizeOfSet(int i) {
			return setSize[findSet(i)];
		}
	}

	/**
	 * private static void trace(int i, int time) { if(i==n) return;
	 *
	 *
	 * long ans=dp(i,time);
	 * if(time+a[i].t<a[i].burn&&(ans==dp(i+1,time+a[i].t)+a[i].cost)) {
	 *
	 * trace(i+1, time+a[i].t);
	 *
	 * l1.add(a[i].idx); return; } trace(i+1,time);
	 *
	 * }
	 **/

	static class incpair implements Comparable<incpair> {
		int a;
		long b;
		int idx;

		incpair(int a, long dirg, int i) {
			this.a = a;
			b = dirg;
			idx = i;
		}

		public int compareTo(incpair e) {
			return (int) (b - e.b);
		}
	}

	static class decpair implements Comparable<decpair> {
		int a;
		long b;
		int idx;

		decpair(int a, long dirg, int i) {
			this.a = a;
			b = dirg;
			idx = i;
		}

		public int compareTo(decpair e) {
			return (int) (e.b - b);
		}
	}

	static long allpowers[];

	static class Quad implements Comparable<Quad> {
		int u;
		int v;
		char state;
		int turns;

		public Quad(int i, int j, char c, int k) {
			u = i;
			v = j;
			state = c;
			turns = k;
		}

		public int compareTo(Quad e) {
			return (int) (turns - e.turns);
		}

	}

	static long dirg[][];
	static Edge[] driver;

	static int n;

	static long manhatandistance(long x, long x2, long y, long y2) {
		return Math.abs(x - x2) + Math.abs(y - y2);
	}

	static long fib[];

	static long fib(int n) {
		if (n == 1 || n == 0) {
			return 1;
		}
		if (fib[n] != -1) {
			return fib[n];
		} else
			return fib[n] = ((fib(n - 2) % mod + fib(n - 1) % mod) % mod);
	}

	static class Point  implements Comparable<Point>{
		long x, y;

		Point(long counth, long counts) {
			x = counth;
			y = counts;
		}

		@Override
		public int compareTo(Point p )
		{
			return Long.compare(p.y*1l*x, p.x*1l*y);
		}

	}

	static long[][] comb;

	static class Triple implements Comparable<Triple> {

		int l;
		int r;
		long cost;
		int idx;

		public Triple(int a, int b, long l1, int l2) {
			l = a;
			r = b;
			cost = l1;
			idx = l2;
		}

		public int compareTo(Triple x) {
			if (l != x.l || idx == x.idx)
				return l - x.l;
			return -idx;
		}

	}

	static TreeSet<Long> primeFactors(long N) // O(sqrt(N) / ln sqrt(N))
	{
		TreeSet<Long> factors = new TreeSet<Long>(); // take abs(N) in case of -ve integers
		int idx = 0, p = primes.get(idx);

		while (p * p <= N) {
			while (N % p == 0) {
				factors.add((long) p);
				N /= p;
			}
			if (primes.size() > idx + 1)
				p = primes.get(++idx);
			else
				break;
		}

		if (N != 1) // last prime factor may be > sqrt(N)
			factors.add(N); // for integers whose largest prime factor has a power of 1
		return factors;
	}

	static boolean visited[];

	/**
	 * static int bfs(int s) { Queue<Integer> q = new LinkedList<Integer>();
	 * q.add(s); int count=0; int maxcost=0; int dist[]=new int[n]; dist[s]=0;
	 * while(!q.isEmpty()) {
	 *
	 * int u = q.remove(); if(dist[u]==k) { break; } for(Pair v: adj[u]) {
	 * maxcost=Math.max(maxcost, v.cost);
	 *
	 *
	 *
	 * if(!visited[v.v]) {
	 *
	 * visited[v.v]=true; q.add(v.v); dist[v.v]=dist[u]+1; maxcost=Math.max(maxcost,
	 * v.cost); } }
	 *
	 * } return maxcost; }
	 **/
	public static boolean FindAllElements(int n, int k) {
		int sum = k;
		int[] A = new int[k];
		Arrays.fill(A, 0, k, 1);

		for (int i = k - 1; i >= 0; --i) {

			while (sum + A[i] <= n) {

				sum += A[i];
				A[i] *= 2;
			}
		}
		if (sum == n) {
			return true;
		} else
			return false;
	}

	static boolean[] vis2;

	static boolean f2 = false;

	static long[][] matMul(long[][] a2, long[][] b, int p, int q, int r) // C(p x r) = A(p x q) x (q x r) -- O(p x q x
																			// r)
	{
		long[][] C = new long[p][r];
		for (int i = 0; i < p; ++i) {
			for (int j = 0; j < r; ++j) {
				for (int k = 0; k < q; ++k) {
					C[i][j] = (C[i][j] + (a2[i][k] % mod * b[k][j] % mod)) % mod;
					C[i][j] %= mod;
				}

			}
		}
		return C;
	}

	static int memo1[];

	static boolean vis[];
	static TreeSet<Integer> set = new TreeSet<Integer>();

	static long modPow(long ways, long count, long mod) // O(log e)
	{
		ways %= mod;
		long res = 1;
		while (count > 0) {
			if ((count & 1) == 1)
				res = (res * ways) % mod;
			ways = (ways * ways) % mod;
			count >>= 1;
		}
		return res % mod;
	}

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

	static int[] isComposite;
	static int[] valid;

	static ArrayList<Integer> primes;
	static ArrayList<Integer> l1;

	static TreeSet<Integer> primus = new TreeSet<Integer>();

	static void sieveLinear(int N)
	{
		int[] lp = new int[N + 1];								//lp[i] = least prime divisor of i
		for(int i = 2; i <= N; ++i)
		{
			if(lp[i] == 0)
			{
				primus.add(i);
				lp[i] = i;
			}
			int curLP = lp[i];
			for(int p: primus)
				if(p > curLP || p * i > N)
					break;
				else
					lp[p * i] = i;
		}
	}

	public static int[] schuffle(int[] p) {
		for (int i = 0; i < p.length; i++) {
			int x = (int) (Math.random() * p.length);
			int temp = p[x];
			p[x] = p[i];
			p[i] = temp;
		}
		return p;
	}

	static int V;
	static long INF = (long) 1E16;

	static class Edge2 {
		int node;
		long cost;
		long next;

		Edge2(int a, int c, Long long1) {
			node = a;
			cost = long1;
			next = c;
		}

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

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

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

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

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

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

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