#include <bits/stdc++.h>
using namespace std;
int comb(int n, int k) {
  int table[n + 1][n + 1];
  for (int i = 0; i <= n; i++) table[i][0] = 1;
  for (int i = 1; i <= k; i++) table[i][i] = 1;
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j < min(i, k + 1); j++) {
      table[i][j] = table[i - 1][j - 1] + table[i - 1][j];
    }
  }
  return table[n][k];
}
int main() {
  int n;
  cin >> n;
  vector<long long> s(n + 1);
  s[0] = 0;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    s[i + 1] = s[i] + a;
  }
  unordered_map<long long, int> mp;
  long long ans = 0;
  for (int i = 0; i < n + 1; i++) mp[s[i]]++;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    if (itr->second > 1) {
      ans += comb(itr->second, 2);
    }
  }
  cout << ans << endl;
  return 0;
}
