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