#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
  long long c = gcd(a, b);
  return ((a / c) * (b / c) * c);
}
const long long INF = 1e9 + 7;
const long long N = 200003;
long long n, a[N], ans = 0, p = -1, r = 1, k = 0;
vector<long long> s;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  s.push_back(0);
  for (long long i = (0); i < (n); ++i) {
    cin >> a[i];
    k += a[i];
    (sort(s.begin(), s.end()));
    long long pp = ((upper_bound(s.begin(), s.end(), k) - s.begin()) -
                    (lower_bound(s.begin(), s.end(), k) - s.begin()));
    if (pp > 0) {
      ans += pp;
      s.push_back(k);
    } else {
      s.push_back(k);
    }
  }
  cout << ans << endl;
  return 0;
}
