#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
  int N;
  cin >> N;
  vector<int> vec(N), sum(N + 1);
  ll ans = 0;
  ll cnt = 0;
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
  }
  sum[0] = 0;
  for (int i = 1; i < N + 1; i++) {
    sum[i] = vec[i - 1] + sum[i - 1];
  }
  map<int, int> mp;
  for (int i = 0; i < N + 1; i++) {
    mp[sum[i]]++;
  }
  for (auto v : mp) {
    if (v.second >= 2) {
      ans += (v.second - 1) * v.second / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
