#include <bits/stdc++.h>
using namespace std;
long long cnt[65536 * 4];
long long a[65536 * 4];
long long s[65536 * 4];
long long n;
int main() {
  long long ans = 0;
  cnt[0] = 1;
  cin >> n;
  for (int i = 1; i <= n; i++)
    scanf("%lld", &a[i]), s[i] = s[i - 1] + a[i], ans += cnt[s[i]]++;
  cout << ans;
  return 0;
}
