#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[((1 << 18) - 1)];
inline int hashFunc(long long x) { return (x & 0x000000000003FFFF); }
void addToHash(long long sumZ) {
  int index, HsumZ, beginP;
  HsumZ = hashFunc(sumZ);
  for (beginP = index = hashIndex[HsumZ]; index > 0;
       index = hashBucket[index].next)
    if (hashBucket[index].number == sumZ) {
      hashBucket[index].times += 1;
      return;
    }
  hashIndex[HsumZ] = (++top);
  hashBucket[top].number = sumZ;
  hashBucket[top].times = 1;
  hashBucket[top].next = beginP;
}
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)) >> 1);
  cout << answer << endl;
}
int main() {
  init();
  work();
  return 0;
}
