#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
class PalseError {};
class Edge {
 public:
  LL from, to, value;
  Edge(LL a, LL b, LL c) {
    from = a;
    to = b;
    value = c;
  }
  Edge(LL a, LL b) {
    from = a;
    to = b;
  }
};
class SegmentTreeOfRMQ {
 private:
  std::vector<LL> dat;
  int N;

 public:
  void init(int n) {
    int s = 1;
    while (s < n) {
      s *= 2;
    }
    dat = std::vector<LL>(s, INT_MAX);
    N = n;
  }
  void update(int i, int x) {
    i += N - 1;
    dat[i] = x;
    while (i > 0) {
      i = (i - 1) / 2;
      dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
    }
  }
  int query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return INT_MAX;
    if (a <= l && r <= b)
      return dat[k];
    else {
      int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
      int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
      return min(vl, vr);
    }
  }
};
int main() {
  int(N);
  cin >> (N);
  LL ruiseki[N + 10];
  ruiseki[0] = 0;
  for (int a = 0; a < (N); ++a) {
    LL(b);
    cin >> (b);
    ruiseki[a + 1] = ruiseki[a] + b;
  }
  map<LL, LL> hoge;
  for (int a = 0; a < (N + 1); ++a) {
    if (hoge.find(ruiseki[a]) == hoge.end()) {
      hoge[ruiseki[a]] = 1;
    } else {
      hoge[ruiseki[a]]++;
    }
  }
  LL ans = 0;
  for (pair<int, int> a : hoge) {
    ans += ((a.second * (a.second - 1)));
  }
  cout << (ans / 2) << endl;
  return 0;
}
