#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<ll> vec;
  ll tmp;
  ll ans = 0;
  for (int i = (0); i < static_cast<int>(N); i++) {
    vec.push_back(0);
    cin >> tmp;
    for (auto& j : (vec)) j += tmp;
    sort((vec).begin(), (vec).end());
    ans += upper_bound((vec).begin(), (vec).end(), 0) -
           lower_bound((vec).begin(), (vec).end(), 0);
  }
  print(ans);
}
template <typename T>
void print(const vector<vector<T>> matrix) {
  for (auto& vec : (matrix)) print(vec);
}
template <typename T>
void print(const vector<T> vec) {
  for (auto& i : (vec)) cout << i << ' ';
  cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
  cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
  cout << head << " ";
  print(args...);
}
