#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
map<int, int> mp;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  long long res = 0, sum = 0;
  mp[0] = 1;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    sum += a;
    res += mp[sum];
    mp[sum]++;
  }
  cout << res << endl;
}
