#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  map<int, int> s;
  vector<int> l(n + 1);
  s[l[0]]++;
  for (int i = 0; i < n; i++) {
    l[i + 1] = l[i] + a[i];
    s[l[i + 1]]++;
  }
  long long ans = 0;
  for (auto p : s) {
    long long num = p.second;
    ans += num * (num - 1) / 2;
  }
  cout << ans << endl;
}
