#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1e5;
long long ara[N + 3];
map<long long, int> mp;
int main() {
  long long n;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) scanf("%lld", &ara[i]);
  mp[0] = 1;
  int cnt = 0;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += ara[i];
    if (mp[sum]) cnt += mp[sum];
    mp[sum]++;
  }
  cout << cnt << endl;
}
