#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long LINF = 1e18;
const double EPS = 1e-9;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int main() {
  int n;
  cin >> n;
  int ans = 0;
  vector<long long> vec(n);
  for (int(i) = 0; (i) < (int)(n); i++) {
    cin >> vec.at(i);
  }
  vector<long long> diff(n + 1);
  diff.at(0) = 0;
  for (int(i) = 0; (i) < (int)(n); i++) {
    diff.at(i + 1) = vec.at(i) + diff.at(i);
  }
  sort((diff).begin(), (diff).end());
  int cou = 1;
  for (int(i) = 0; (i) < (int)(n); i++) {
    if (diff.at(i) != diff.at(i + 1)) {
      cou = 1;
    }
    if (diff.at(i) == diff.at(i + 1)) {
      ans += cou;
      cou++;
    }
  }
  cout << ans << endl;
  return 0;
}
