#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, temp, now = 0;
  long long int ans = 0;
  map<int, int> m;
  m.insert(make_pair(0, 1));
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &temp);
    now += temp;
    if (m.find(now) != m.end())
      ans += m[now]++;
    else
      m.insert(make_pair(now, 1));
  }
  printf("%lld\n", ans);
}
