#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", 3, "inline")
using namespace std;
int mon[20] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
long long gcd(long long x, long long y) {
  return ((y == 0) ? x : gcd(y, x % y));
}
long long n, a[200010];
map<long long, int> mp;
int x[200010];
long long cnt = 1;
long long ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) a[i] += a[i - 1];
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0 && i != 1) ans++;
    if (mp[a[i]] == 0) mp[a[i]] = cnt++;
    x[mp[a[i]]]++;
  }
  for (int i = 1; i < cnt; i++) ans += (x[i] * (x[i] - 1) / 2);
  cout << ans;
  return 0;
}
