#include <bits/stdc++.h>
using namespace std;
int dy[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dx[] = {1, -1, 0, 0, 1, -1, -1, 1};
long long n, a[300000];
int main() {
  cin >> n;
  for (int i = 0; i < (n); i++) {
    cin >> a[i + 1];
  }
  for (int i = 0; i < (n); i++) {
    a[i + 1] += a[i];
  }
  map<long long, long long> m;
  for (int i = 0; i < (n + 1); i++) {
    if (m.find(a[i]) == m.end())
      m[a[i]] = 1;
    else
      m[a[i]]++;
  }
  long long ans = 0;
  for (map<long long, long long>::iterator itr = m.begin(); itr != m.end();
       itr++) {
    ans += itr->second * (itr->second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
