#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 62;
const int inf = 1 << 29;
int main() {
  int n;
  scanf("%d", &n);
  long long ans = 0;
  vector<long long> a(n);
  for (int i = (0); i < (n); ++i) {
    scanf("%lld", &a[i]);
    a[i] += i == 0 ? 0 : a[i - 1];
  }
  sort((a).begin(), (a).end());
  for (int i = (0); i < (n); ++i) {
    int tem = 1;
    for (int j = i + 1; j < n + 1 && a[j] == a[i]; j++) {
      tem++;
    }
    if (a[i] == 0) {
      ans += (tem * (tem + 1)) / 2;
    } else {
      ans += (tem * (tem - 1)) / 2;
    }
    i += tem - 1;
  }
  printf("%lld \n", ans);
  return 0;
}
