#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e7;
int main() {
  long long n;
  cin >> n;
  vector<long long> v(n, 0);
  vector<long long> sum(n, 0);
  map<long long, long long> m;
  m[0]++;
  for (long long i = 0; i < (n); ++i) {
    cin >> v[i];
    sum[i + 1] = sum[i] + v[i];
    m[sum[i + 1]]++;
  }
  long long ans = 0;
  for (auto itr = m.begin(); itr != m.end(); ++itr) {
    ans += itr->second * (itr->second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
