#include <bits/stdc++.h>
using namespace std;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using vi32 = std::vector<i32>;
using vu32 = std::vector<u32>;
using vf32 = std::vector<f32>;
using vi64 = std::vector<i64>;
using vu64 = std::vector<u64>;
using vf64 = std::vector<f64>;
using vvi32 = std::vector<vi32>;
using vvu32 = std::vector<vu32>;
using vvf32 = std::vector<vf32>;
using vvi64 = std::vector<vi64>;
using vvu64 = std::vector<vu64>;
using vvf64 = std::vector<vf64>;
using pi32 = std::pair<i32, i32>;
using pu32 = std::pair<u32, u32>;
using pf32 = std::pair<f32, f32>;
using pi64 = std::pair<i64, i64>;
using pu64 = std::pair<u64, u64>;
using pf64 = std::pair<f64, f64>;
const i32 INF = 0x3F3F3F3F;
const i64 INF64 = 0x3F3F3F3F3F3F3F3F;
const f64 EPS = 1e-8;
const i32 MOD = 1000000007;
static const f64 PI = 3.1415926535897932;
static const f64 NAPIER = 2.7182818284590452;
const char alphabetl[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                            'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                            's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const char alphabetu[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
                            'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
                            'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
i32 dx[4] = {1, 0, -1, 0};
i32 dy[4] = {0, 1, 0, -1};
template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T1>
std::istream& operator>>(std::istream& is, std::tuple<T1>& t) {
  is >> std::get<0>(t);
  return is;
}
template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::tuple<T1, T2>& t) {
  is >> std::get<0>(t) >> std::get<1>(t);
  return is;
}
template <typename T1, typename T2, typename T3>
std::istream& operator>>(std::istream& is, std::tuple<T1, T2, T3>& t) {
  is >> std::get<0>(t) >> std::get<1>(t) >> std::get<2>(t);
  return is;
}
template <typename T1, typename T2, typename T3, typename T4>
std::istream& operator>>(std::istream& is, std::tuple<T1, T2, T3, T4>& t) {
  is >> std::get<0>(t) >> std::get<1>(t) >> std::get<2>(t) >> std::get<3>(t);
  return is;
}
template <typename T1, typename T2, typename T3, typename T4, typename T5>
std::istream& operator>>(std::istream& is,
                         const std::tuple<T1, T2, T3, T4, T5>& t) {
  is >> std::get<0>(t) >> std::get<1>(t) >> std::get<2>(t) >> std::get<3>(t) >>
      std::get<4>(t);
  return is;
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
          typename T6>
std::istream& operator>>(std::istream& is,
                         const std::tuple<T1, T2, T3, T4, T5, T6>& t) {
  is >> std::get<0>(t) >> std::get<1>(t) >> std::get<2>(t) >> std::get<3>(t) >>
      std::get<4>(t) >> std::get<5>(t);
  return is;
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
          typename T6, typename T7>
std::istream& operator>>(std::istream& is,
                         const std::tuple<T1, T2, T3, T4, T5, T6, T7>& t) {
  is >> std::get<0>(t) >> std::get<1>(t) >> std::get<2>(t) >> std::get<3>(t) >>
      std::get<4>(t) >> std::get<5>(t) >> std::get<6>(t);
  return is;
}
template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& as) {
  for (i32 i = (i32)(0); i < (i32)(((i32)(as).size())); i++) is >> as[i];
  return is;
}
template <typename T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& ss) {
  for (auto a : ss) {
    if (a != ss.begin()) os << " ";
    os << a;
  }
  return os;
}
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p) {
  os << p.first << " " << p.second;
  return os;
}
template <typename K, typename V>
std::ostream& operator<<(std::ostream& os, const std::map<K, V>& m) {
  bool isF = true;
  for (auto& p : m) {
    if (!isF) os << std::endl;
    os << p;
    isF = false;
  }
  return os;
}
template <typename T1>
std::ostream& operator<<(std::ostream& os, const std::tuple<T1>& t) {
  os << std::get<0>(t);
  return os;
}
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::tuple<T1, T2>& t) {
  os << std::get<0>(t) << " " << std::get<1>(t);
  return os;
}
template <typename T1, typename T2, typename T3>
std::ostream& operator<<(std::ostream& os, const std::tuple<T1, T2, T3>& t) {
  os << std::get<0>(t) << " " << std::get<1>(t) << " " << std::get<2>(t);
  return os;
}
template <typename T1, typename T2, typename T3, typename T4>
std::ostream& operator<<(std::ostream& os,
                         const std::tuple<T1, T2, T3, T4>& t) {
  os << std::get<0>(t) << " " << std::get<1>(t) << " " << std::get<2>(t) << " "
     << std::get<3>(t);
  return os;
}
template <typename T1, typename T2, typename T3, typename T4, typename T5>
std::ostream& operator<<(std::ostream& os,
                         const std::tuple<T1, T2, T3, T4, T5>& t) {
  os << std::get<0>(t) << " " << std::get<1>(t) << " " << std::get<2>(t) << " "
     << std::get<3>(t) << " " << std::get<4>(t);
  return os;
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
          typename T6>
std::ostream& operator<<(std::ostream& os,
                         const std::tuple<T1, T2, T3, T4, T5, T6>& t) {
  os << std::get<0>(t) << " " << std::get<1>(t) << " " << std::get<2>(t) << " "
     << std::get<3>(t) << " " << std::get<4>(t) << " " << std::get<5>(t);
  return os;
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
          typename T6, typename T7>
std::ostream& operator<<(std::ostream& os,
                         const std::tuple<T1, T2, T3, T4, T5, T6, T7>& t) {
  os << std::get<0>(t) << " " << std::get<1>(t) << " " << std::get<2>(t) << " "
     << std::get<3>(t) << " " << std::get<4>(t) << " " << std::get<5>(t) << " "
     << std::get<6>(t);
  return os;
}
template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& as) {
  for (i32 i = (i32)(0); i < (i32)(as.size()); i++) {
    if (i != 0) os << " ";
    os << as[i];
  }
  return os;
}
template <typename T>
std::ostream& operator<<(std::ostream& os,
                         const std::vector<std::vector<T>>& as) {
  for (i32 i = (i32)(0); i < (i32)(((i32)(as).size())); i++) {
    if (i != 0) os << std::endl;
    os << as[i];
  }
  return os;
}
void Main();
int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}
void Main() {
  i64 N;
  cin >> N;
  vi64 A(N), B(N + 1);
  B[0] = 0;
  for (i32 i = (i32)(0); i < (i32)(N); i++) cin >> A[i], B[i + 1] = B[i] + A[i];
  sort((B).begin(), (B).end());
  i64 ans = 0;
  i64 cnt = 1;
  i64 now = B[0];
  for (int i = 1; i <= N; i++) {
    if (now == B[i]) {
      cnt++;
    } else {
      ans += cnt * (cnt - 1) / 2;
      now = B[i];
      cnt = 1;
    }
  }
  cout << (ans) << "\n";
  ;
}
