#include <bits/stdc++.h>
using namespace std;
const long long int MAX = 1e12;
int main() {
  int n;
  cin >> n;
  map<long long int, long long int> mp;
  mp[0] = 1;
  int ans = 0;
  long long int x;
  long long int rc = 0;
  for (int i = 0; i < n; i++) {
    cin >> x;
    rc += x;
    if (mp[rc]) ans += mp[rc];
    mp[rc]++;
  }
  cout << ans;
}
