#include <bits/stdc++.h>
using namespace std;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
  std::fill((T*)array, (T*)(array + N), val);
}
struct Edge {
  int from, to;
  long long w;
  bool operator<(const Edge& rhs) const {
    return make_pair((w), (make_pair((from), (to)))) <
           make_pair((rhs.w), (make_pair((rhs.from), (rhs.to))));
  }
};
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long m, long long n) { return m * n / gcd(m, n); }
long long mod_pow(long long x, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = (res * x) % 1000000007LL;
    x = (x * x) % 1000000007LL;
    n >>= 1;
  }
  return res;
}
long long divmod(long long a, long long b) {
  return (a * mod_pow(b, 1000000007LL - 2)) % 1000000007LL;
}
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) {}
  bool unionSet(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  bool isroot(int x) { return data[x] < 0; }
  int size(int x) { return -data[root(x)]; }
};
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = (0); (n) > i; i++) {
    cin >> a[i];
  }
  map<int, int> cnt;
  long long int acc = 0, ans = 0;
  for (int i = (0); (n) > i; i++) {
    cnt[acc]++;
    acc += a[i];
    ans += cnt[acc];
  }
  cout << ans << endl;
  return 0;
}
