#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[i];
  }
  vector<int> s(n + 1, 0);
  for (int i = 0; i < n; ++i) {
    s[i + 1] = s[i] + a[i];
  }
  map<int, int> mp;
  for (int i = 0; i < n + 1; ++i) {
    ++mp[s[i]];
  }
  int res = 0;
  for (auto it : mp) {
    int num = it.second;
    res += num * (num - 1) / 2;
  }
  cout << res << endl;
  return 0;
}
