#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
std::vector<int> vec;
map<int, int> m;
int main() {
  cin >> n;
  vec.assign(n, 0);
  for (int i = 0; i < n; i++) {
    std::cin >> vec[i];
  }
  vec.insert(vec.begin(), 0);
  for (int i = 1; i <= n; i++) {
    vec[i] = vec[i] + vec[i - 1];
  }
  for (int i = 0; i <= n; i++) {
    m[vec[i]]++;
  }
  ll ans = 0;
  for (auto e : m) {
    ans += e.second * (e.second - 1) / 2;
  }
  cout << ans << std::endl;
}
