#include <bits/stdc++.h>
using namespace std;
long long a, b, c[200005], ans;
map<int, int> n;
int main() {
  cin >> a;
  n[0] = 1;
  for (int s = 1; s <= a; s++) {
    cin >> b;
    c[s] = b + c[s - 1];
    ans = ans + n[c[s]];
    n[c[s]]++;
  }
  cout << ans << endl;
}
