#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e7;
long long nCr(long long n, long long r) {
  long long ans = 1;
  for (long long i = n; i > n - r; --i) {
    ans = ans * i;
  }
  for (long long i = 1; i < r + 1; ++i) {
    ans = ans / i;
  }
  return ans;
}
int main() {
  long long n;
  cin >> n;
  vector<long long> v(n, 0);
  vector<long long> sum(n, 0);
  map<long long, long long> m;
  for (long long i = 0; i < (n); ++i) {
    cin >> v[i];
    sum[i + 1] = sum[i] + v[i];
    m[sum[i + 1]]++;
  }
  long long ans = 0;
  for (auto i = m.begin(); i != m.end(); i++) {
    if (i->first == 0) {
      ans += nCr(i->second + 1, 2);
    } else {
      ans += nCr(i->second, 2);
    }
  }
  cout << ans << endl;
  return 0;
}
