#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<long long> s(n + 1);
  map<long long, int> c;
  for (int i = 0; i < n; i++) s[i + 1] = s[i] + a[i];
  for (int i = 0; i < n + 1; i++) c[s[i]]++;
  int ans = 0;
  for (auto itr : c) {
    int num = itr.second;
    ans += num * (num - 1) / 2;
  }
  cout << ans << endl;
}
