#include <bits/stdc++.h>
using namespace std;
int main() {
  unordered_map<long long, int> m;
  int n;
  scanf("%d", &n);
  long long sum = 0;
  m[sum] = 1;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    sum += a;
    if (m.find(sum) == m.end())
      m[sum] = 1;
    else
      m[sum] += 1;
  }
  long long count = 0;
  for (auto iter = m.begin(); iter != m.end(); iter++) {
    count += iter->second * (iter->second - 1) / 2;
  }
  printf("%lld\n", count);
  return 0;
}
