#include <bits/stdc++.h>
using namespace std;
using LLI = long long int;
int main(void) {
  int N, a, res = 0, sum = 0;
  vector<int> vec;
  vector<int> vec2;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a;
    vec.push_back(a);
  }
  sum = vec[0];
  vec2.push_back(sum);
  for (int i = 1; i < N; i++) {
    sum = sum + vec[i];
    vec2.push_back(sum);
  }
  sort(vec2.begin(), vec2.end());
  for (int i = 0; i < N; i++) {
    if (vec2[i] == 0) {
      res++;
    } else {
      break;
    }
  }
  for (int i = vec2[0]; i <= vec2[vec2.size() - 1]; i++) {
    a = count(vec2.begin(), vec2.end(), i);
    a = a * (a - 1) / 2;
    res += a;
  }
  cout << res << endl;
}
