#include <bits/stdc++.h>
using namespace std;
double pi = 3.141592653589793;
long long mul[214514];
long long divt[214514];
long long fact(long long x, long long y) {
  if (y == 1)
    return x;
  else if (y % 2 == 0)
    return fact(x * x % 1000000007, y / 2);
  else
    return fact(x * x % 1000000007, y / 2) * x % 1000000007;
}
long long C(long long n, long long t) {
  if (n == 1) return 0;
  return mul[n] * divt[t] % 1000000007 * divt[n - t] % 1000000007;
}
signed main() {
  long long n;
  cin >> n;
  long long a[214514];
  long long sum[214514];
  vector<long long> key;
  set<long long> ch;
  for (long long i = 0; i < n; i++) {
    cin >> a[i + 1];
    if (i == 0)
      sum[i + 1] = a[i + 1];
    else
      sum[i + 1] = sum[i] + a[i + 1];
    key.push_back(sum[i + 1]);
    ch.insert(sum[i + 1]);
  }
  mul[0] = 1;
  for (long long i = 1; i < 214514; i++) mul[i] = mul[i - 1] * i % 1000000007;
  divt[214513] = fact(mul[214513], 1000000007 - 2);
  for (long long i = 214512; i >= 0; i--)
    divt[i] = divt[i + 1] * (i + 1) % 1000000007;
  key.push_back(0);
  sort(key.begin(), key.end());
  long long ans = 0;
  for (auto i : ch) {
    long long h = upper_bound(key.begin(), key.end(), i) -
                  lower_bound(key.begin(), key.end(), i);
    ans += C(h, 2);
  }
  cout << ans << endl;
  return 0;
}
