#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
map<long long, long long> ma;
long long n, a[N], s, ans;
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
  ma[0] = 1;
  for (int i = 1; i <= n; ++i) {
    s += a[i];
    ans += ma[s];
    ma[s]++;
  }
  printf("%lld\n", ans);
}
