#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n + 1);
  for (int i = 0; i < n; i++) cin >> a[i + 1];
  for (int i = 0; i < n; i++) a[i + 1] += a[i];
  sort(a.begin(), a.end());
  long long ans = 0;
  vector<int> res;
  int p = a[0];
  int q = 1;
  for (int i = 0; i < n; i++) {
    if (a[i] != a[i + 1]) {
      res.push_back(q);
      q = 1;
    } else
      q++;
  }
  res.push_back(q);
  for (int i = 0; i < res.size(); i++) ans += res[i] * (res[i] - 1) / 2;
  cout << ans << endl;
}
