#include <bits/stdc++.h>
using namespace std;
static const long long maxLL = (long long)1 << 62;
const int mod = 1000000007;
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, 1, 0, -1};
signed main() {
  map<long long, long long> mp;
  mp[0]++;
  long long n;
  cin >> n;
  long long a[100010];
  long long s = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    s += a[i];
    mp[s]++;
  }
  long long ans = 0;
  for (auto kv : mp) {
    ans += kv.second * (kv.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
