#include <bits/stdc++.h>
using namespace std;
int dx[4]{-1, +1, 0, 0};
int dy[4]{0, 0, -1, +1};
int gcd(int a, int b) {
  if (b == 0) {
    return a;
  }
  if (a < b) return gcd(b, a);
  return gcd(b, a % b);
}
int main() {
  int n;
  cin >> n;
  vector<long long> a(n, 0);
  for (int i = 0; i < (int)n; i++) cin >> a[i];
  long long sum = 0;
  map<long long, int> mp;
  mp[0]++;
  for (int i = 0; i < (int)n; i++) {
    sum += a[i];
    mp[sum]++;
  }
  int ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    ans += (itr->second) * (itr->second - 1) / 2;
  }
  cout << ans << endl;
}
