#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
  int n, ans = 0;
  cin >> n;
  vector<long long> a(n), s(n + 1, 0);
  map<long long, long long> mp;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    s[i + 1] = a[i] + s[i];
    mp[s[i + 1]]++;
  }
  mp[0]++;
  for (auto m : mp)
    if (m.second > 1) ans += m.second * (m.second - 1) / 2;
  cout << ans << endl;
  return 0;
}
