#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, c = 1, ans = 0;
  cin >> n;
  int s[n + 1] = {0};
  for (int i = 1; i < n + 1; i++) {
    int a;
    cin >> a;
    s[i] = s[i - 1] + a;
  }
  sort(s, s + (n + 1));
  int t = s[0];
  for (int i = 1; i < n + 1; i++) {
    if (t != s[i]) {
      ans += c * (c - 1) / 2;
      c = 1;
    } else {
      c++;
    }
    t = s[i];
  }
  ans += c * (c - 1) / 2;
  cout << ans << endl;
}