#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using G = vector<vector<int>>;
int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = (0); i < (n); i++) cin >> a[i];
  LL ans = 0;
  map<int, int> m;
  LL sum = 0;
  m[0] = 1;
  for (int i = (0); i < (n); i++) {
    sum += a[i];
    if (m.find(sum) != m.end()) {
      ans += m[sum];
    }
    m[sum] += 1;
  }
  printf("%lld\n", ans);
  return 0;
}
