#include <bits/stdc++.h>
using namespace std;
long long sett[(100000 * 2) + 1];
int n, cnt;
map<long long, long long> mp;
bool binary(int x, int y, long long v) {
  while (x < y) {
    int mid = (x + y) / 2;
    if (sett[mid] == v)
      return true;
    else if (sett[mid] > v)
      y = mid;
    else
      x = mid + 1;
  }
  return false;
}
int main() {
  cnt = 0;
  mp.clear();
  scanf("%d", &n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    sum += x;
    mp[sum]++;
    int j;
    for (j = 0; j < cnt; j++) {
      if (sett[j] == sum) break;
    }
    if (j < cnt) continue;
    sett[cnt++] = sum;
  }
  long long ans = 0, tmp;
  for (int i = 0; i < cnt; i++) {
    tmp = mp[sett[i]];
    ans += (tmp * (tmp - 1) / 2);
  }
  cout << ans + mp[0] << endl;
  return 0;
}
