#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  long long a[111111];
  a[0] = 0;
  cin >> n;
  for (long long i = 1; i < n + 1; i++) {
    long long b;
    cin >> b;
    a[i] = a[i - 1] + b;
  }
  sort(a, a + n + 1);
  a[n + 1] = -1;
  long long co = 0, ans = 0;
  for (long long i = 0; i < n + 1; i++) {
    if (a[i] == a[i + 1])
      co++;
    else {
      co++;
      ans += co * (co - 1) / 2;
      co = 0;
    }
  }
  cout << ans << endl;
}
