#include <bits/stdc++.h>
using namespace std;
const long long int inf = 2222222222222222222LL;
const long long int mod = 1000000007LL;
long long int n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
long long int dx[5] = {1, -1, 0, 0, 0}, dy[5] = {0, 0, 1, -1, 0};
long long int ddx[9] = {1, -1, 0, 0, 1, 1, -1, -1, 0},
              ddy[9] = {0, 0, 1, -1, 1, -1, 1, -1, 0};
int main(void) {
  cin >> n;
  multiset<long long int> st;
  st.insert(0);
  long long int sum = 0;
  for (long long int i = (long long int)(0LL); i < (long long int)(n); i++) {
    scanf("%lld", &tmp);
    sum += tmp;
    auto it1 = st.upper_bound(sum);
    auto it2 = st.lower_bound(sum);
    cnt = distance(it2, st.end()) - distance(it1, st.end());
    ans += cnt;
    st.insert(sum);
  }
  cout << ans << endl;
  return 0;
}
