#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ;
  cin >> n;
  vector<long long> a(n), acc(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  acc[0] = a[0];
  for (int i = 1; i < n; i++) acc[i] = a[i] + acc[i - 1];
  int ans = 0;
  for (int i = 0; i < n; i++)
    if (acc[i] == 0) ++ans;
  for (int i = 0; i < 10; i++) {
    int num = 0;
    for (int j = 0; j < n; j++)
      if (acc[j] == i) ++num;
    ans += num * (num - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
