#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 100;
int a[maxn];
int sum[maxn];
int n;
long long ans;
map<long long, int> cnt;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum[i] = sum[i - 1] + a[i];
    cnt[sum[i]]++;
  }
  for (auto w : cnt) {
    ans += w.second * (w.second - 1) / 2;
    if (w.first == 0) ans += w.second;
  }
  cout << ans << endl;
  return 0;
}
