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