#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int X10 = 1024, X11 = 2048, X12 = 4096, X13 = 8196, X14 = 16392,
          X15 = 32786, X16 = 65536, X17 = 131072, X18 = 262144, X19 = 524288,
          X20 = 1048576;
vector<string> v;
void g(int k, int n, string s) {
  if (s.size() == n) {
    v.emplace_back(s);
    return;
  }
  for (int i = 1; i < k + 1; ++i) {
    g(k, n, s + to_string(i));
  }
}
string f(int k, int n) {
  for (int i = 0; i < n; ++i) {
    g(k, i + 1, "");
  }
  sort(v.begin(), v.end());
  return v[v.size() / 2 - 1];
}
long long A[200000];
void _() {
  int n;
  cin >> n;
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    long long t;
    cin >> t;
    sum += t;
    A[i] = sum;
  }
  sort(A, A + n);
  long long res = 0, t = 0, cnt = 0, cnt_zero = 0;
  for (int i = 0; i < n; ++i) {
    if (A[i] == t)
      cnt++;
    else {
      res += cnt * (cnt + 1) / 2;
      cnt = 0;
    }
    t = A[i];
  }
  res += cnt * (cnt + 1) / 2;
  cout << res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  _();
  return 0;
}
