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