#include <bits/stdc++.h>
int N;
int* A;
int getCount(int t) { return t * (t - 1) / 2; }
int main() {
  scanf("%d\n", &N);
  int a;
  long long tmp = 0;
  std::priority_queue<long long> que;
  que.push(0);
  for (int i = 0; i < N; i++) {
    scanf("%d", &a);
    tmp += a;
    que.push(tmp);
  }
  int res = 0;
  tmp = 1;
  int sub = que.top();
  que.pop();
  while (!que.empty()) {
    if (sub == que.top()) {
      tmp++;
    } else {
      res += getCount((int)tmp);
      tmp = 1;
      sub = que.top();
    }
    que.pop();
  }
  res += getCount((int)tmp);
  printf("%d\n", res);
  return 0;
}
