#include <bits/stdc++.h>
using namespace std;
long long a[200010];
int main() {
  int n;
  cin >> n;
  a[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
  }
  sort(a, a + n + 1);
  a[n + 1] = -1;
  long long ans = 0;
  for (int i = 0; i <= n; i++) {
    int j = i;
    while (a[j + 1] == a[i]) j++;
    ans += (j - i + 1) * (j - i) / 2;
    i = j;
  }
  cout << ans << endl;
  cin >> ans;
}
