#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
clock_t startTime;
long double getTime() {
  return (long double)(clock() - startTime) / CLOCKS_PER_SEC;
}
int main() {
  startTime = clock();
  int n;
  cin >> n;
  long long array[n];
  long long sum[n + 1];
  long long count = 0;
  sum[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> array[i];
    sum[i + 1] = sum[i] + array[i];
  }
  sort(sum, sum + n + 1);
  int i = 0;
  while (i < n + 1) {
    int j = i;
    while (j < n + 1 && sum[i] == sum[j]) j++;
    count += ((j - i) * (j - i - 1)) / 2;
    i = j;
  }
  cout << count;
  return 0;
}
