#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
int main() {
  int n;
  cin >> n;
  vector<long long int> s(n + 1);
  s[0] = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    s[i + 1] = s[i] + (long long int)a;
  }
  map<long long int, int> count;
  for (int i = 0; i <= n; i++) {
    count[s[i]]++;
  }
  long long int ans = 0;
  for (auto itr = count.begin(); itr != count.end(); itr++) {
    int num = itr->second;
    if (num <= 1) continue;
    ans += (num - 1) * num / 2;
  }
  cout << ans << endl;
}
