#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, d, a[300000], c, ans, b[300000];
  ans = 0;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  b[0] = 0;
  for (long long i = 1; i < n + 1; i++) {
    b[i] = b[i - 1] + a[i - 1];
  }
  sort(b, b + n + 1);
  d = 0;
  for (long long i = 0; i < n; i++) {
    if (b[i] == b[i + 1])
      d++;
    else {
      ans += (d + 1) * d / 2;
      d = 0;
    }
  }
  ans += (d + 1) * d / 2;
  printf("%d", ans);
}
