#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
long long gcd(long long x, long long y) { return (y == 0) ? x : gcd(y, x % y); }
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
bool IsPrime(int num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      return false;
    }
  }
  return true;
}
int main() {
  int n, cnt = 0;
  long long ans = 0;
  cin >> n;
  long long v[n + 1];
  v[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    v[i] += v[i - 1];
  }
  sort(v, v + n + 1);
  for (int i = 0; i < n + 1; i++) {
    cnt++;
    if (v[i] != v[i + 1] || i == n) {
      ans += (cnt * (cnt - 1) / 2);
      cnt = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
