#include <bits/stdc++.h>
using namespace std;
long a[111111];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%ld", a + i);
    a[i] += a[i - 1];
  }
  sort(a, a + n + 1);
  long r = 0, m = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[i - 1])
      m = 0;
    else
      m++;
    r += m;
  }
  cout << r << endl;
  return 0;
}
