#include <bits/stdc++.h>
using namespace std;
long long arr[200005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    long long tmp;
    cin >> tmp;
    arr[i] = arr[i - 1] + tmp;
  }
  sort(arr + 1, arr + 1 + n);
  long long cnt = 1;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (arr[i] != arr[i - 1]) {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    } else {
      cnt++;
    }
  }
  ans += cnt * (cnt - 1) / 2;
  cout << ans;
}
