#include <bits/stdc++.h>
using namespace std;
long long sumZ = 0;
int Ai;
int N;
struct T {
  long long number, times;
  int next;
} hashBucket[210001];
int top = 0;
int hashIndex[100009];
inline int hashFunc(long long x) {
  if (x < 0) x = -x;
  return (x % 100007);
}
void addToHash(long long sumZ) {
  int index, HsumZ;
  HsumZ = hashFunc(sumZ);
  for (index = hashIndex[HsumZ]; hashBucket[index].next > 0;
       index = hashBucket[index].next)
    if (hashBucket[index].number == sumZ) break;
  if (hashBucket[index].number == sumZ)
    hashBucket[index].times += 1;
  else {
    hashIndex[HsumZ] = (++top);
    hashBucket[top].number = sumZ;
    hashBucket[top].times = 1;
    hashBucket[top].next = index;
  }
}
void init() {
  memset(hashBucket, -1, sizeof(hashBucket));
  scanf("%d", &N);
  addToHash(0);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &Ai);
    sumZ = sumZ + Ai;
    addToHash(sumZ);
  }
}
void work() {
  long long answer = 0;
  for (int i = 1; i <= top; ++i)
    answer = answer + (((hashBucket[i].times) * (hashBucket[i].times - 1)) / 2);
  cout << answer << endl;
}
int main() {
  init();
  work();
  return 0;
}
