#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>

typedef long long LL;
std::map<LL, int> S;

int main() {
  int n;
  scanf("%d", &n);
  LL ans = 0, s = 0;
  for (int i = 0, x; i < n; ++i) {
    ++S[s];
    scanf("%d", &x);
    ans += S[s += x];
  }
  printf("%lld\n", ans);
  return 0;
}
