#include <bits/stdc++.h>
using namespace std;
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) {}
  void 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;
    }
  }
  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]); }
  int size(int x) { return -data[root(x)]; }
};
int gcd(int a, int b) {
  if (a < b) swap(a, b);
  int k = a % b;
  if (k == 1) return 1;
  if (k == 0) return b;
  int ans = gcd(b, k);
  return ans;
}
int digisum(long long a) {
  int sum = 0;
  while (a) {
    sum += a % 10;
    a /= 10;
  }
  return sum;
}
int main() {
  int n, m;
  cin >> n;
  vector<int> a(n);
  vector<long long> s(n + 1);
  map<int, int> mp;
  s[0] = 0;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s[i + 1] = (s[i] + a[i]);
  }
  for (int i = 0; i < s.size(); i++) {
    ans += mp[s[i]];
    mp[s[i]]++;
  }
  cout << ans << endl;
}
