#include <bits/stdc++.h>
using namespace std;
long long sum[200010];
int num[100000010], tot, ans, n, a[2000010];
map<long long, int> mp;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum[i] = sum[i - 1] + a[i];
    if (mp[sum[i]] == 0) mp[sum[i]] = ++tot;
  }
  for (int i = 1; i <= n; i++) {
    if (sum[i] == 0) ans++;
    if (num[mp[sum[i]]] == 0) {
      num[mp[sum[i]]]++;
    } else {
      ans += num[mp[sum[i]]];
      num[mp[sum[i]]]++;
    }
  }
  cout << ans << endl;
}
