#include <bits/stdc++.h>
using namespace std;
void quick_sort(int s[], int left, int right) {
  int p, l, r, t;
  l = left, r = right;
  p = s[(l + r) / 2];
  while (1) {
    while (s[l] < p) l++;
    while (s[r] > p) r--;
    if (l >= r) break;
    t = s[r];
    s[r] = s[l];
    s[l] = t;
    l++;
    r--;
  }
  if (left < l - 1) quick_sort(s, left, l - 1);
  if (right > r + 1) quick_sort(s, r + 1, right);
}
int comb(int n, int r) {
  if (n == 0)
    return 1;
  else if (r == 0)
    return 1;
  else if (r == n)
    return 1;
  else
    return comb(n - 1, r) + comb(n - 1, r - 1);
}
int main() {
  int n, t, l, r, count = 0;
  cin >> n;
  int a[n], s[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> t;
    a[i] = t;
  }
  s[0] = 0;
  for (int i = 1; i < n + 1; i++) {
    s[i] = a[i - 1] + s[i - 1];
  }
  sort(s, s + n + 1);
  l = 0;
  r = 1;
  while (1) {
    while (s[l] == s[r]) {
      r++;
      if (r > n) break;
    }
    if (r - l > 1) {
      count += comb(r - l, 2);
      l = r - 1;
    }
    if (r > n) break;
    l++;
    r++;
  }
  cout << count << endl;
}
