#include <bits/stdc++.h>
using namespace std;
int asc(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int desc(const void *a, const void *b) { return *(int *)b - *(int *)a; }
int main() {
  long long n, ans = 0, cnt = 0, cnt2 = 1;
  cin >> n;
  long long a, s[n + 1];
  s[0] = 0;
  for (int(i) = (1); (i) < (n + 1); ++(i)) {
    cin >> a;
    s[i] = s[i - 1] + a;
  }
  qsort(s, n + 1, sizeof(long long), asc);
  for (int(i) = 0; (i) < (n + 1); ++(i)) {
    if (s[i] == s[i + 1]) {
      ++cnt;
    } else {
      for (int(j) = (1); (j) < (cnt + 1); ++(j)) {
        cnt2 = cnt2 * j;
      }
      if (cnt != 0) {
        ans += cnt2;
      }
      cnt2 = 1;
      cnt = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
