#include <bits/stdc++.h>
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;
template <typename T>
void printA(vector<T> &printArray, char between = ' ') {
  int paSize = printArray.size();
  for (int i = 0; i < paSize; i++) {
    cerr << printArray[i] << between;
  }
  if (between != '\n') {
    cerr << endl;
  }
}
int n;
long long a[111111];
long long b[111111];
int main() {
  cin >> n;
  for (int(i) = (0); (i) < (n); ++(i)) {
    cin >> a[i];
    b[i + 1] = a[i];
    b[i + 1] += b[i];
  }
  long long ans = 0;
  map<long long, long long> mp;
  for (int(i) = (0); (i) < (n + 1); ++(i)) {
    mp[b[i]]++;
  }
  for (auto x : mp) {
    long long t = x.second;
    ans += t * (t - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
