#include <bits/stdc++.h>
using namespace std;
long long int fun(long long int f) { return (1 + f) * f / 2; }
long long int a[200005];
long long int s[200005];
int main() {
  int n;
  cin >> n;
  s[0] = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) s[i] += (s[i - 1] + a[i]);
  sort(s + 1, s + n + 1);
  long long int m = 0;
  long long int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 0) continue;
    if (s[i] == s[i - 1])
      m++;
    else {
      ans += fun(m);
      m = 0;
    }
  }
  ans += fun(m);
  m = 0;
  for (int i = 1; i <= n; i++)
    if (s[i] == 0) m++;
  ans += fun(m);
  cout << ans << endl;
  return 0;
}
