#include <bits/stdc++.h>
using namespace std;
int n;
long long a[100005], ans;
long long getnum(long long x) { return (x * x - x) / 2; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    a[i] += a[i - 1];
  }
  sort(a, a + n + 1);
  long long length = 1;
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[i - 1]) {
      ans += getnum(length);
      length = 1;
    }
    if (a[i] == a[i - 1]) length++;
  }
  ans += getnum(length);
  printf("%d\n", ans);
  return 0;
}
