#include <bits/stdc++.h>
using namespace std;
long int com_2(int a) {
  long int c;
  c = a * (a - 1) / 2;
  return c;
}
int main() {
  int n;
  long int ans = 0;
  cin >> n;
  vector<long int> vec(n + 1);
  vec[0] = 0;
  for (int i = 0; i < (int)(n); i++) {
    int p;
    cin >> p;
    vec[i + 1] = vec[i] + p;
  }
  map<long int, int> mp;
  for (int i = 0; i < (int)(n + 1); i++) mp[vec[i]]++;
  for (auto &p : mp) {
    int a = p.second;
    ans += com_2(a);
  }
  cout << ans << endl;
  return 0;
}
