#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, int> sum_map;
  int N;
  scanf("%d", &N);
  int a, sum = 0;
  sum_map[0]++;
  for (int i = 0; i < N; i++) {
    scanf("%d", &a);
    sum += a;
    sum_map[sum]++;
  }
  long long result = 0;
  for (auto i : sum_map) {
    result += i.second * (i.second - 1) / 2;
  }
  cout << result;
  return 0;
}
