#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
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; }
int main() {
  long long N, ans;
  cin >> N;
  long long A[N + 1];
  vector<long long> S;
  S.push_back(0);
  for (int i = (1); i <= (N); ++i) {
    cin >> A[i];
    S.push_back(S.at(i - 1) + A[i]);
  }
  sort((S).begin(), (S).end());
  long long t = S.at(0), cnt = 1;
  for (int i = 1; i < S.size(); ++i) {
    if (t != S.at(i) || i == S.size() - 1) {
      t = S.at(i);
      if (i == S.size() - 1) cnt++;
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    } else {
      cnt++;
    }
  }
  cout << ans << '\n';
  return 0;
}
