#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  map<int, long long> mp;
  long long sum = 0, ans = 0;
  for (int i = 0; i < (N); i++) {
    long long a;
    cin >> a;
    sum += a;
    if (sum == 0) ans++;
    mp[sum]++;
  }
  for (auto m : mp) {
    ans += max(0LL, (m.second - 1) * m.second / 2);
  }
  cout << ans << endl;
  return 0;
}
