#include <bits/stdc++.h>
using namespace std;
int N;
int main() {
  cin >> N;
  map<long long, int> mp;
  long long sum = 0;
  mp[0]++;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    sum += a;
    mp[sum]++;
  }
  long long ans = 0;
  for (auto e : mp) {
    ans += (mp[e.first] - 1) * mp[e.first] / 2;
  }
  cout << ans << endl;
  return 0;
}
