#include<stdio.h>
#include <stdlib.h>
long long compare_int(const void *a, const void *b)
{
    return  *(long long*)a - *(long long*)b;;
}
int main() {
    int n, i,j;
    long long a[200002], sum[200002],ans=0, count;
    scanf("%d", &n);
    for (i = 1; i <= n; i++)
        scanf("%lld", &a[i]);
    sum[0] = 0;
    for (i = 1; i <= n; i++)
            sum[i] = sum[i - 1] + a[i];
    qsort(sum, n+1, sizeof(long long), compare_int);
    count = 1;
    long long memory=0;
    for (i = 1; i <= n; i++) {
        if (sum[i] == memory)
            count++;
        else {
            if (count > 1)
                ans += count * (count - 1) / 2;
            count = 1;
            memory = sum[i];
        }
    }
    if (count > 1)
        ans += count * (count - 1) / 2;
    printf("%lld\n", ans);
    return 0;
}
