#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = mod * mod;
const long long d2 = (mod + 1) / 2;
const long double EPS = 1e-10;
const long double PI = acos(-1.0);
int ABS(int a) { return max(a, -a); }
long long ABS(long long a) { return max(a, -a); }
long double ABS(long double a) { return max(a, -a); }
int main(void) {
  int n, ans = 0, cnt = 1;
  cin >> n;
  vector<long> a(n), b(n + 2), c(n + 2);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  b[0] = 0;
  for (int i = 0; i < n; ++i) {
    b[i + 1] = b[i] + a[i];
  }
  b[n + 1] = 100000000011111;
  c = b;
  sort(b.begin(), b.end());
  for (int i = 0; i < n + 1; ++i) {
    if (c[i + 1] == 0) ++ans;
    if (b[i] == b[i + 1]) ++cnt;
    if ((b[i] != b[i + 1]) && (cnt != 1)) {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  printf("%d\n", ans);
  return 0;
}
