#include <bits/stdc++.h>
using namespace std;
const int maxn = 200006;
struct hzw {
  int bef;
  int id;
  int beid;
} all[maxn];
bool cmp(hzw a, hzw b) { return a.bef < b.bef; }
bool cmp2(hzw a, hzw b) { return a.beid < b.beid; }
int cnt[maxn], n;
long long ans;
int main() {
  cin >> n;
  for (int i = 1, a; i <= n; ++i) {
    scanf("%d", &a);
    all[i].bef = all[i - 1].bef + a;
    all[i].beid = i;
  }
  sort(all + 1, all + 1 + n, cmp);
  int tot = 0;
  for (int i = 1; i <= n; i++) {
    if (all[i].bef != all[i - 1].bef) {
      all[i].id = ++tot;
    } else
      all[i].id = all[i - 1].id;
  }
  sort(all + 1, all + 1 + n, cmp2);
  for (int i = 1; i <= n; ++i) {
    if (all[i].bef == 0) ans++;
    ans += cnt[all[i].id];
    cnt[all[i].id]++;
  }
  cout << ans << endl;
  return 0;
}
