#include <bits/stdc++.h>
using namespace std;
long long a, n, sum, ans;
map<long long, int> m;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    sum += a;
    ans += m[sum];
    m[sum]++;
  }
  cout << ans;
}
