#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int a[n];
  map<int, int> count;
  long long int prefix[n + 1];
  memset(prefix, 0, sizeof(prefix));
  count[prefix[0]] = 1;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    prefix[i + 1] = prefix[i] + a[i];
    count[prefix[i + 1]] += 1;
  }
  map<int, int>::iterator it;
  long long int ans = 0;
  long long int second = 0;
  for (it = count.begin(); it != count.end(); it++) {
    second = it->second;
    for (long long int i = second - 1; i >= 0; i--) {
      ans += i;
    }
  }
  cout << ans << endl;
}
