#include <bits/stdc++.h>
using namespace std;
int s[200005];
int main() {
  int n;
  cin >> n;
  for (int(i) = (0); (i) <= (n - 1); (i)++) {
    int a;
    cin >> a;
    if (i == 0)
      s[i] = a;
    else
      s[i] = s[i - 1] + a;
  }
  s[n] = 0;
  sort(s, s + n + 1);
  int same = 1;
  int ans = 0;
  for (int(i) = (1); (i) <= (n); (i)++) {
    if (s[i] == s[i - 1])
      same++;
    else {
      if (same == 1) continue;
      ans += same * (same - 1) / 2;
      same = 1;
    }
  }
  if (same != 1) ans += same * (same - 1) / 2;
  cout << ans << endl;
}
