#include <bits/stdc++.h>
using namespace std;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> s(n + 1, 0);
  for (int i = 1; i < n + 1; i++) {
    int a;
    cin >> a;
    s[i] = s[i - 1] + a;
  }
  long long ans = 0;
  map<long long, int> cnt;
  cnt[0] = 1;
  for (int i = 0; i < n + 1; i++) {
    ans += cnt[s[i]];
    cnt[s[i]]++;
  }
  cout << ans << endl;
}
