#include <bits/stdc++.h>
using namespace std;
long long n;
long long s[(20005)];
int main(void) {
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    long long tmp;
    cin >> tmp;
    s[i] = s[i - 1] + tmp;
  }
  sort(s, s + n + 1);
  long long ans = 0;
  long long j = 0;
  while (j <= n) {
    long long cnt = 0;
    while (s[j] == s[j + cnt]) {
      cnt++;
    }
    j += cnt;
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
