#include <bits/stdc++.h>
using namespace std;
int vx[] = {0, 0, -1, 1};
int vy[] = {1, -1, 0, 0};
int dx[] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy[] = {1, 1, 1, 0, 0, -1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
const long long mod = 1e9 + 7;
const int INF = INT_MAX / 2;
int n;
int a[200020];
long long s[200020];
int cnt = 0;
map<long long, int> mp;
int main() {
  cin >> n;
  for (int i = 0; i < int(n); i++) cin >> a[i];
  for (int i = 0; i < int(n); i++) {
    s[i] = 0;
  }
  s[0] = a[0];
  for (int i = 0; i < int(n - 1); i++) {
    s[i + 1] += s[i] + a[i + 1];
  }
  mp[0] = 1;
  for (int i = 0; i < int(n); i++) {
    auto itr = mp.find(s[i]);
    if (itr != mp.end()) {
      mp[s[i]] = mp[s[i]] + 1;
    } else {
      mp[s[i]] = 1;
    }
  }
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    cnt += (itr->second) * (itr->second - 1) / 2;
  }
  cout << cnt << endl;
  return 0;
}
