#include <bits/stdc++.h>
using namespace std;
long long n, ans, x, m;
map<long long, long long> a;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &m);
    x += m;
    ans += a[x];
    if (x == 0) ans++;
    a[x]++;
  }
  cout << ans;
  return 0;
}
