#include <bits/stdc++.h>
using namespace std;
stringstream devnull;
template <class C>
inline void vcin(C &c);
template <class C, class D>
inline void vcin(C &c, D &d);
template <class C>
inline void vcout(const C &c, const string separate = "\n");
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  vcin(a);
  vector<long long> s(n + 1, 0);
  for (int i = 0; i < n; i++) s[i + 1] = s[i] + a[i];
  map<int, long long> m;
  for (auto e : s) {
    m[e]++;
  }
  int ans = 0;
  for (auto e : m) {
    int n = e.second;
    if (n >= 2) {
      ans += (n * (n - 1) / 2);
    }
  }
  cout << ans << "\n";
  return 0;
}
template <class C>
inline void vcin(C &c) {
  for (auto &a : c) {
    cin >> a;
  }
}
template <class C, class D>
inline void vcin(C &c, D &d) {
  for (auto it1 = c.begin(), it2 = d.begin(); it1 != c.end() && it2 != d.end();
       it1++, it2++) {
    cin >> *it1 >> *it2;
  }
}
template <class C>
inline void vcout(const C &c, const string separate) {
  for (auto it = c.begin(); it != c.end(); it++) {
    if (it != c.begin()) cout << separate;
    cout << *it;
  }
}
