#include <bits/stdc++.h>

using namespace std;

long long n, a, ans;
long long sum;
map<long long, int>mp;

int main()
{
  cin >> n;
  mp[0]++;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    sum += a;
    ans += mp[sum];
    mp[sum]++;
  }
  cout << ans;
  return 0;
}
