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