#include <bits/stdc++.h>
const int maxn = 100005;
using namespace std;
long long a[maxn], n, now, ans;
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", a + i), a[i] += a[i - 1];
  sort(a, a + n + 1), now = 1;
  for (int i = 1; i <= n; i++)
    if (a[i] != a[i - 1])
      now = 1;
    else
      ans += now, now++;
  cout << ans << endl;
  return 0;
}
