#include <bits/stdc++.h>
const long long MOD = 1000000007;
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> v(N);
  cin >> v[0];
  for (int i = 1; i < N; i++) {
    long long a;
    cin >> a;
    v[i] = v[i - 1] + a;
  }
  map<int, int> mp;
  for (int i = 0; i < N; i++) mp[v[i]]++;
  mp[0]++;
  long long ans = 0;
  for (auto i = mp.begin(); i != mp.end(); i++) {
    long long t = i->second;
    ans += t * (t - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
