#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  map<int, int> mp;
  int s = 0, ans = 0;
  mp[0] = 1;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    s += x;
    ans += mp[s];
    mp[s]++;
  }
  cout << ans << endl;
  return 0;
}
