#include <bits/stdc++.h>
using namespace std;
void File() {
  freopen("A.in", "r", stdin);
  freopen("A.out", "w", stdout);
}
const int maxn = 1e5 + 10;
int n;
long long a[maxn], sum[maxn], ans;
map<long long, long long> b;
int main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
  for (register int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + a[i];
  b[0] = 1;
  for (register int i = 1; i <= n; ++i) {
    ans += b[sum[i]];
    ++b[sum[i]];
  }
  cout << ans << endl;
  return 0;
}
