#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cnt = 0, ans = 0;
  vector<long long> a;
  cin >> n;
  a.resize(n + 1);
  a[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i + 1];
    a[i + 1] += a[i];
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n + 1; i++) {
    ans += cnt;
    cnt++;
    if (a[i] != a[i + 1]) cnt = 0;
  }
  cout << ans << endl;
  return 0;
}
