#include <bits/stdc++.h>
using namespace std;
char mapData[100][100];
int costData[100][100];
long long imos[(int)1e+5 * 2 + 1];
long long input[(int)1e+5 * 2 + 1];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
long long nC2(long long n) {
  if (n <= 1) return 0;
  return n * (n - 1) / 2;
}
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    input[i] = a;
  }
  imos[0] = input[0];
  for (int i = 1; i < N; i++) {
    imos[i] = input[i] + imos[i - 1];
  }
  map<long long, long long> m;
  set<long long> s;
  for (int i = 0; i < N; i++) {
    s.insert(imos[i]);
    if (m[imos[i]] == 0)
      m[imos[i]] = 1;
    else
      m[imos[i]]++;
  }
  int ans = m[0];
  for (long long l : s) {
    ans += nC2(m[l]);
  }
  cout << ans << "\n";
  return 0;
}
