#include <bits/stdc++.h>
using namespace std;
long long sumZ = 0;
int Ai;
int N;
struct T {
  long long number, times;
  T* next;
} hashBucket[210001];
int top = 0;
int hashIndex[70009];
inline int hashFunc(long long x) {
  if (x < 0) x = -x;
  return (x % 100007);
}
inline void addToHash(long long sumZ) {
  int HsumZ;
  T *index, *beginP;
  HsumZ = hashFunc(sumZ);
  for (beginP = index = &hashBucket[hashIndex[HsumZ]]; (index->times > 0);
       index = index->next)
    if (index->number == sumZ) {
      index->times++;
      return;
    }
  top++;
  hashIndex[HsumZ] = top;
  index = &hashBucket[top];
  index->number = sumZ;
  index->times = 1;
  index->next = beginP;
}
void init() {
  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;
}
