#include <bits/stdc++.h>
using namespace std;
int dy[4] = {0, 0, 1, -1};
int dx[4] = {1, -1, 0, 0};
long nCr(int n, int r) {
  long ans = 1;
  for (int i = n; i > n - r; i--) {
    ans *= i;
  }
  for (int i = 1; i <= r; i++) {
    ans /= i;
  }
  return ans;
}
int n, a[200002], c[200002];
int main() {
  cin >> n;
  c[0] = 0;
  map<int, int> mp;
  mp[c[0]]++;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    c[i + 1] = c[i] + a[i];
    mp[c[i + 1]]++;
  }
  int ans = 0;
  for (auto a : mp) {
    int p = a.second;
    if (p >= 2) {
      ans += nCr(p, 2);
    }
  }
  cout << ans << endl;
}
