#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
const long long INF = 1LL << 60;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<long long> s(n + 1);
  for (int i = 0; i < n; i++) s[i + 1] = s[i] + a[i];
  map<long long, int> nums;
  for (int i = 0; i < n + 1; i++) nums[s[i]]++;
  long long ans = 0;
  for (auto it : nums) {
    int num = it.second;
    ans += num * (num - 1) / 2;
  }
  std::cout << ans << '\n';
}
