#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
  int n;
  cin >> n;
  long long a[n + 1];
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  for (int i = 0; i < (int)(n - 1); i++) a[i + 1] += a[i];
  a[n] = 0;
  sort(a, a + n + 1);
  long long ans = 0;
  int cnt = 0;
  long long pos = longinf;
  for (int i = 0; i < (int)(n + 1); i++) {
    if (a[i] == pos)
      cnt++;
    else {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
      pos = a[i];
    }
  }
  ans += cnt * (cnt - 1) / 2;
  cout << ans << endl;
  return 0;
}
