#include <bits/stdc++.h>
using namespace std;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
struct io {
  io() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
};
const int INF = INT_MAX / 2;
const long long int LLINF = 1LL << 60;
constexpr long long int MOD = 1000000007;
const double EPS = 1e-9;
signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<long long int> A(N);
  for (int i = 0; i < (N); ++i) {
    cin >> A[i];
  }
  vector<long long int> acc(N + 1);
  unordered_map<long long int, vector<int>> vtois;
  vtois.emplace(acc[0], vector<int>());
  vtois[acc[0]].push_back(0);
  for (int i = 0; i < (N); ++i) {
    acc[i + 1] = acc[i] + A[i];
    if (vtois.find(acc[i + 1]) == vtois.end()) {
      vtois.emplace(acc[i + 1], vector<int>());
    }
    vtois[acc[i + 1]].push_back(i + 1);
  }
  long long int ct = 0;
  while (true) {
    auto itr = vtois.begin();
    if (itr == vtois.end()) break;
    auto pr = *itr;
    int n = pr.second.size();
    ct += n * (n - 1) / 2;
    vtois.erase(pr.first);
  }
  cout << (ct) << '\n';
}
