#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-14;
const double PI = acos(-1.0);
int main() {
  int n;
  scanf("%d", &n);
  vector<long long> v(n + 1);
  for (int i = (int)(0); i < (int)(n); i++) {
    long long a;
    scanf("%lld", &a);
    v[i + 1] = v[i] + a;
  }
  sort(v.begin(), v.end());
  int ans = 0;
  while (v.size() > 0) {
    long long num = v[0];
    int cnt = count(v.begin(), v.end(), num);
    if (cnt == 1) {
      v.erase(v.begin(), v.begin() + 1);
      continue;
    }
    ans += (cnt * (cnt - 1)) / 2;
    v.erase(v.begin(), v.begin() + cnt);
  }
  printf("%d\n", ans);
}
