#include <bits/stdc++.h>
using namespace std;
int find(vector<long long> v, long long p) {
  for (int i = 0; i < v.size(); i++)
    if (v[i] == p) return i;
  return -1;
}
long long a[200010];
vector<long long> v;
int a2[200010];
int main() {
  int n;
  cin >> n;
  a[0] = 0;
  v.push_back(0);
  a2[0] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
    int f = find(v, a[i]);
    if (f == -1) {
      v.push_back(a[i]);
      a2[v.size() - 1] = 1;
    } else
      a2[f]++;
  }
  long long ans = 0;
  for (int i = 0; i < v.size(); i++) {
    ans += a2[i] * (a2[i] - 1) / 2;
  }
  cout << ans << endl;
}
