#include <bits/stdc++.h>
using namespace std;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
const int INF = (((1 << 30) - 1) << 1) + 1;
const int nINF = 1 << 31;
const int N = 2e5 + 1;
int n, a[N], p[N];
long long choose2(long long k) { return (k * (k - 1)) / 2; }
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = (1); i <= (n); i++) cin >> a[i];
  p[0] = 0;
  for (int i = (1); i <= (n); i++) p[i] = p[i - 1] + a[i];
  map<int, int> m;
  for (int i = (0); i <= (n); i++) m[p[i]]++;
  long long ans = 0;
  for (auto& pr : m) ans += choose2(pr.second);
  cout << ans << endl;
  return 0;
}
