#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ss = stringstream;
using ul = unsigned long long;
template <typename T>
inline T LCM(T a, T b) {
  return (a * b) / GCD(a, b);
}
template <typename T>
inline T GCD(T a, T b) {
  ll t;
  while (a) {
    t = a;
    a = b % a;
    b = t;
  }
  return b;
}
template <typename T>
inline T _max(T a, T b, T c) {
  return max(max(a, b), c);
}
template <typename T>
inline T _min(T a, T b, T c) {
  return min(min(a, b), c);
}
template <typename T>
inline string toString(T a) {
  return to_string(a);
}
template <typename T>
inline void toInt(string s, T &x) {
  ss str(s);
  str >> x;
}
inline void lower(string &s) {
  for (__typeof((s).begin()) it = (s).begin(); it != (s).end(); ++it)
    *it = tolower(*it);
}
inline void upper(string &s) {
  for (__typeof((s).begin()) it = (s).begin(); it != (s).end(); ++it)
    *it = toupper(*it);
}
const ll inf = 999999999999999999;
bool palin(string s) {
  string s1 = s;
  reverse(s.begin(), s.end());
  return (s == s1);
}
ll triangle(ll n) { return (n * (n + 1)) / 2; }
bool check(ll n) {
  if (n == 1) return 0;
  if (n == 2 or n == 3) return 1;
  if (n % 2 == 0 or n % 3 == 0) return 0;
  for (ll i = 5; i * i <= n; i += 6)
    if (n % i == 0 or n % (i + 2) == 0) return 0;
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n;
  cin >> n;
  vector<int> s(n + 1);
  int x;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    s[i] = s[i - 1] + x;
  }
  sort((s).begin(), (s).end());
  int i = 0, ans = 0;
  while (i <= n) {
    int y = s[i];
    int cnt = 0;
    while (s[i] == y and i <= n) {
      i++;
      cnt++;
    }
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans;
  cout << "\n";
  return 0;
}
