#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  int n;
  cin >> n;
  long long s = 0;
  vector<long long> v;
  v.push_back(0);
  for (int i = 0; i < (int)(n); ++i) {
    long long k;
    cin >> k;
    s += k;
    v.push_back(s);
  }
  int c = 1;
  long long an = 0;
  sort(v.begin(), v.end());
  ;
  long long b = v[0];
  for (int i = 1; i <= (int)(n); ++i) {
    if (v[i] == b)
      c++;
    else {
      an += (c * (c - 1)) / 2;
      b = v[i];
      c = 1;
    }
  }
  an += (c * (c - 1)) / 2;
  cout << an << endl;
  return 0;
}
