#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
const int MAX_N = 100100;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  vector<long long> sum(n + 1, 0);
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + v[i - 1];
  sort(sum.begin(), sum.end());
  map<long long, long long> mp;
  for (int i = 0; i < sum.size(); i++) mp[sum[i]]++;
  vector<long long> w(MAX_N, 0);
  long long e = 1;
  for (int i = 2; i < MAX_N; i++) {
    w[i] = w[i - 1] + e;
    e++;
  }
  long long res = 0;
  for (auto x : mp) {
    res += w[x.second];
  }
  cout << res << endl;
  return 0;
}
