import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int[] xs) {
    long sum = 0;
    long[long] d = [0: 1];
    foreach (x; xs) {
        sum += x;
        d[sum]++;
    }

    long ans = 0;
    foreach (k, v; d) {
        ans += (v * (v - 1)) / 2;
    }
    return ans;
}

void main() {
    readint;
    auto xs = readints;
    writeln(calc(xs));
}
