#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
double pi = 3.1415926535;
int main() {
  int n, b, c = 0, ans = 0;
  cin >> n;
  int a[n + 1];
  a[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> b;
    a[i + 1] = b + c;
    c = a[i + 1];
  }
  c = 1;
  sort(a, a + n + 1);
  for (int i = 1; i < n + 1; i++) {
    if (a[i] != a[i - 1]) {
      ans += c * (c - 1) / 2;
      c = 1;
    } else
      c++;
  }
  ans += c * (c - 1) / 2;
  cout << ans << endl;
  return 0;
}
