#include <bits/stdc++.h>
using namespace std;
const int EPS = 1e-9;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while (cin >> n) {
    ;
    int sum = 0;
    vector<int> a(n + 1);
    a[0] = 0;
    for (int i = (1); i < (n + 1); i++) {
      int newa;
      cin >> newa;
      sum += newa;
      a[i] = sum;
    };
    sort((a).begin(), (a).end());
    ;
    int ans = 0;
    int cnt = 1;
    int prev = a[0];
    for (int i = (1); i < (n + 1); i++) {
      if (a[i] == prev) {
        ans += cnt;
        cnt++;
      } else {
        prev = a[i];
        cnt = 1;
      }
    }
    cout << ans << endl;
    ;
  }
  return 0;
}
