#include <bits/stdc++.h>
using namespace std;
int INF = (1LL << 30) - 1;
int MOD = 1e9 + 7;
int main() {
  int N;
  cin >> N;
  long long sum = 0;
  unordered_map<long long, int> mp;
  for (int i = int(0); i < int(N); ++i) {
    int X;
    cin >> X;
    sum += X;
    mp[sum]++;
  }
  long long ans = 0;
  for (auto p : mp) {
    if (p.first == 0) ans += p.second;
    ans += (p.second * (p.second - 1)) / 2;
  }
  cout << ans << endl;
}
