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