#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long ans = 0;
  cin >> n;
  int a[n], sum[n + 1];
  sum[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < n + 1; i++) {
    sum[i] = a[i - 1] + sum[i - 1];
  }
  map<int, int> mp;
  for (int i = 0; i < n + 1; i++) {
    mp[sum[i]]++;
  }
  for (auto p : mp) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans;
}
