#include <bits/stdc++.h>
using namespace std;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;
int main() {
  int n;
  cin >> n;
  map<long long, int> mp;
  long long sum = 0;
  mp[sum]++;
  for (int i = 1; i <= (n); i++) {
    int a;
    cin >> a;
    sum += a;
    mp[sum]++;
  }
  int ans = 0;
  for (auto x : mp) ans += x.second * (x.second - 1) / 2;
  cout << ans << endl;
}
