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