#include <bits/stdc++.h>

using namespace std;

int main()
{
  int N;
  vector<long long> v(N+1, 0);
  map<long long, long long> m;
  for (int i = 0; i < N; i++) {
    cin >> v[i+1];
    v[i+1] += v[i];
    m[v[i]]++;
  }
  long long res = 0;
  for (auto x : m) {
    res += x.second * (x.second - 1) / 2
  }
  cout << res << endl;
}