#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using pii = pair<int, int>;
int N;
ll a[200010];
int main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    cin >> a[i];
  }
  for (int i = 2; i <= N; ++i) {
    a[i] += a[i - 1];
  }
  sort(a, a + N + 1);
  int i = 0;
  int ans = 0;
  while (i <= N) {
    ll tmp = a[i];
    int cnt = 0;
    i++;
    while (i <= N && a[i] == tmp) {
      ++i;
      ++cnt;
    }
    ans += cnt * (cnt + 1) / 2;
  }
  cout << (ans) << '\n';
}
