#include <bits/stdc++.h>
using namespace std;
long long n, a[100009], b[100009];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = b[i - 1] + a[i];
  }
  sort(b, b + n + 1);
  long long c = 1, s = 0;
  for (int i = 1; i <= n; i++) {
    if (b[i] == b[i - 1])
      c++;
    else
      c = 1;
    s += c - 1;
  }
  cout << s << endl;
  return 0;
}
