#include <bits/stdc++.h>
const int INF = 1e9;
const long long LLINF = 1e18;
using namespace std;
int dy[] = {0, 1, 0, -1};
int dx[] = {1, 0, -1, 0};
int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
long long N;
long long A[200010];
long long d[200010];
map<int, int> m;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    d[i + 1] = A[i];
  }
  m[d[0]]++;
  for (int i = 1; i < N + 1; i++) {
    d[i] += d[i - 1];
    m[d[i]]++;
  }
  int ans = 0;
  for (auto e : m) {
    ans += e.second * (e.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
