#include <bits/stdc++.h>
using namespace std;
long long int modpow(long long int a, int n) {
  if (n == 0) return 1;
  if (n == 1) return a;
  long long int wk = modpow(a, n / 2);
  long long int ret = 0;
  if (n % 2 == 0) {
    ret = 1;
  } else {
    ret = a;
  }
  return (((ret * wk) % 1000000007) * wk) % 1000000007;
}
long long int gcd(long long int a, long long int b) {
  long long int tmp;
  if (a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }
  long long int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
long long int lcm(long long int a, long long int b) {
  long long int wk_int;
  wk_int = (a * b) % 1000000007;
  long long int ret;
  ret = (wk_int * modpow(gcd(a, b), 1000000007 - 2)) % 1000000007;
  return ret;
}
bool isPrime(int n) {
  if (n == 1) return false;
  if (n == 2) return true;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
bool comp(const pair<long long int, vector<int>> a,
          const pair<long long int, vector<int>> b) {
  if (a.first != b.first) {
    return a.first < b.first;
  } else {
    return a.second < b.second;
  }
}
int solve(string str) {
  if (str == "") {
    return solve("3") + solve("5") + solve("7");
  }
  long long int num = stoi(str);
  if (num >= 1e9) return 0;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto& i : a) cin >> i;
  vector<long long int> ruiseki(n + 1);
  ruiseki[0] = 0;
  for (int i = 1; i <= n; i++) {
    ruiseki[i] = ruiseki[i - 1] + a[i - 1];
  }
  sort(ruiseki.begin(), ruiseki.end());
  long long int ans = 0;
  int wk = 1;
  int pre = ruiseki[0];
  for (int i = 1; i < ruiseki.size(); i++) {
    if (pre == ruiseki[i]) {
      wk++;
    } else {
      ans += (wk * (wk - 1)) / 2;
      wk = 1;
      pre = ruiseki[i];
    }
  }
  ans += (wk * (wk - 1)) / 2;
  cout << ans << endl;
  return 0;
}
