#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long int b[n + 1];
  b[0] = 0;
  for (long long i = 0; i < n; i++) b[i + 1] = b[i] + a[i];
  map<int, int> m;
  for (long long i = 0; i < n + 1; i++) m[b[i]]++;
  long long int ans = 0;
  for (auto i = m.begin(); i != m.end(); ++i) {
    long long int x = i->second;
    ans += x * (x - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
