#include <bits/stdc++.h>
using namespace std;
const long long INF = 100100100100100100;
const long long MOD = 1000000007;
long long combination(long long n, long long r) {
  if (n < r) return 0;
  if (r == 0 || r == n)
    return 1;
  else if (r == 1)
    return n;
  return (combination(n - 1, r - 1) + combination(n - 1, r));
}
bool checkKaibun(string str) {
  string checkStr = str;
  reverse(checkStr.begin(), checkStr.end());
  if (str == checkStr)
    return true;
  else
    return false;
}
int main() {
  int N;
  cin >> N;
  vector<long long> a(N);
  for (long long i = 0; i < N; i++) cin >> a[i];
  vector<long long> sum(N + 1);
  sum[0] = 0;
  for (long long i = 0; i < N; i++) {
    sum[i + 1] = sum[i] + a[i];
  }
  map<long long, int> m;
  for (long long i = 0; i < N + 1; i++) {
    m[sum[i]]++;
  }
  long long ans = 0;
  for (auto x : m) {
    ans += (x.second * (x.second - 1)) / 2;
  }
  cout << ans << endl;
}
