#include <bits/stdc++.h>
using namespace std;
int a[200010];
map<int, int> mp;
int ct(int k) {
  int sum = 0;
  for (int i = 1; i <= k; i++) sum += i;
  return sum;
}
int main() {
  int n;
  cin >> n;
  int x = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    x += a[i];
    mp[x]++;
  }
  mp[0]++;
  map<int, int>::iterator iter;
  int ans = 0;
  for (iter = mp.begin(); iter != mp.end(); iter++) {
    int x = iter->first;
    int y = iter->second;
    if (y == 1) continue;
    ans += ct(y - 1);
  }
  cout << ans << endl;
}
