#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = (1LL << 31) - 1;
const double pi = acos(-1);
int main() {
  int n;
  cin >> n;
  vector<long long> vec(n + 1);
  map<long long, int> mp;
  long long ans = 0;
  vec[0] = 0;
  for (long long i = 0; i < (n); i++) {
    long long a;
    cin >> a;
    vec[i + 1] = vec[i] + a;
  }
  sort(vec.begin(), vec.end());
  for (long long i = 0; i < (n + 1); i++) {
    mp[vec[i]]++;
  }
  for (auto p : mp) {
    ans += (p.second) * (p.second - 1) / 2;
  }
  cout << ans << endl;
}
