#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  map<int64_t, int> mp;
  int64_t sum = 0;
  cin >> N;
  mp[0] = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    sum += a;
    if (mp.count(sum) > 0) {
      mp[sum]++;
    } else {
      mp[sum] = 0;
    }
  }
  int64_t ans = 0;
  for (auto &x : mp) {
    ans += (x.second) * (x.second + 1) / 2;
  }
  cout << ans << endl;
  return (0);
}
