#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  map<int, int> m;
  int t = 0;
  m[0] = 1;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    t += a;
    if (m.find(t) == m.end()) {
      m[t] = 1;
    } else {
      m[t]++;
    }
  }
  long long ans = 0;
  for (auto i : m) {
    ans += i.second * (i.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
