#include <bits/stdc++.h>
using ll = long long;
constexpr int MAX_N = 200000;
int N;
int A[MAX_N];
int S[MAX_N + 1];
std::vector<int> vs;
std::set<int> uS;
ll tri[MAX_N + 1];
int main() {
  scanf("%d", &N);
  for (int i = (0); i < (N); ++i) scanf("%d", A + i);
  S[0] = 0;
  vs.push_back(S[0]);
  uS.insert(S[0]);
  for (int i = (0); i < (N); ++i) {
    S[i + 1] = S[i] + A[i];
    vs.push_back(S[i + 1]);
    uS.insert(S[i + 1]);
  }
  std::sort(vs.begin(), vs.end());
  tri[0] = 0;
  for (int i = (0); i < (N); ++i) tri[i + 1] = tri[i] + i + 1;
  ll ans = 0;
  for (auto it = uS.begin(); it != uS.end(); ++it) {
    ans += tri[std::upper_bound(vs.begin(), vs.end(), *it) -
               std::lower_bound(vs.begin(), vs.end(), *it) - 1];
  }
  printf("%lld\n", ans);
  return 0;
}
