#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  vector<int> b(n + 1, 0);
  map<int, int> sum;
  sum[0] = 1;
  for (int i = 1; i < n + 1; i++) {
    b[i] = a[i - 1] + b[i - 1];
    if (sum.count(b[i]))
      sum[b[i]]++;
    else
      sum[b[i]] = 1;
  }
  int ans = 0;
  for (auto it : sum) {
    int num = it.second;
    ans += num * (num - 1) / 2;
  }
  cout << ans << endl;
}
