#include <bits/stdc++.h>
using namespace std;
int N, ans = 0;
vector<int> a, s;
map<int, int> mp;
int combine(int s) { return s * (s - 1) / 2; }
void solve() {
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    if (itr->second >= 2) ans += combine(itr->second);
  }
  cout << ans << endl;
}
int main() {
  cin >> N;
  a.resize(N), s.resize(N + 1, 0);
  for (int i = 0, i_len = (N); i < i_len; ++i) cin >> a[i];
  mp[s[0]]++;
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    s[i + 1] = a[i] + s[i];
    mp[s[i + 1]]++;
  }
  solve();
}
