#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
map<long long, int> mp;
int main() {
  int n;
  scanf("%d", &n);
  long long ret = 0, sum = 0;
  mp[0]++;
  for (int i = 0; i < n; i++) {
    long long a;
    scanf("%lld", &a);
    sum += a;
    ret += mp[sum];
    mp[sum]++;
    cout << "  sum=" << sum << "  ret=" << ret << endl;
  }
  printf("%lld\n", ret);
  return 0;
}
