#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template <class T>
inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  cin.tie(0), ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < int(n); i++) cin >> a[i];
  map<long long, int> mp;
  long long sum = 0;
  mp[0]++;
  for (int i = 0; i < int(n); i++) {
    sum += a[i];
    mp[sum]++;
  }
  int ans = 0;
  for (auto x : mp) ans += x.second * (x.second - 1) / 2;
  cout << ans;
  cout << "\n";
  return 0;
}
