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