#include <bits/stdc++.h>
using namespace std;
vector<int> v;
vector<int> s;
int comb(int x) { return x * (x - 1) / 2; }
int main() {
  int n;
  cin >> n;
  v.resize(n + 1);
  s.resize(n + 1);
  v[0] = 0;
  s[0] = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> v[i];
  }
  long long int sum = 0;
  long long int ans = 0;
  for (int i = 1; i <= n; ++i) {
    sum += v[i];
    s[i] = sum;
  }
  sort(s.begin(), s.end());
  int i = 0;
  while (i < n) {
    int count = 1, c = s[i++];
    while (c == s[i]) {
      ++count;
      ++i;
      if (i >= n) break;
    }
    ans += count * (count - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
