#include <bits/stdc++.h>
using namespace std;
using cpx = complex<double>;
using namespace std::literals;
using Int = long long;
using Double = long double;
#ifdef __GNUG__
#define _GLIBCXX_DEBUG
#endif
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define F first
#define S second
#define perm(c)   \
    sort(ALL(c)); \
    for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))
vector<Int> IntsIn(int n) {
    auto v = vector<Int>(0);
    for (int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        v.push_back(a);
    }
    return v;
}
template <typename T>
void Puts(T x) {
    cout << x << endl;
}
void setPrecision(int num = 20) {
    std::cout << std::fixed << std::setprecision(num);
}
template <typename T>
T Max(T a) {
    return a;
}
template <typename T, typename... Args>
T Max(T a, Args... args) {
    return std::max(Max(args...), a);
}
template <typename T>
T Min(T a) {
    return a;
}
template <typename T, typename... Args>
T Min(T a, Args... args) {
    return std::min(Min(args...), a);
}
template <typename T>
bool vector_contains(std::vector<T> vec, T value) {
    return (std::distance(vec.begin(), std::find(vec.begin(), vec.end(), value)) != vec.size());
}
template <typename T>
long indexOf(std::vector<T> &vec, const T &value) {
    auto result = std::distance(vec.begin(), std::find(vec.begin(), vec.end(), value));
    return ((long)result == (long)vec.size()) ? -1 : result;
}
template <typename T>
void removeAt(std::vector<T> &vec, unsigned int index) {
    vec.erase(vec.begin() + index);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &value) {
    std::fill((T *)array, (T *)(array + N), value);
}
struct Container {};
template <class>
struct Ignore {
    typedef Container type;
};
template <class T, class X = Container>
struct PrintObj {
    void operator()(T value) {
        std::cout << value;
    }
};
template <class T>
struct PrintObj<T, typename Ignore<typename T::iterator>::type> {
    void operator()(T value) {
        std::cout << std::endl
                  << "{";
        bool isFirst = true;
        for (auto a : value) {
            if (!isFirst) {
                std::cout << ", ";
            }
            PrintObj<typename T::value_type>()(a);
            isFirst = false;
        }
        std::cout << "}";
    }
};
template <class T>
void Print(T value) {
    PrintObj<T>()(value);
}
template <class T, class U>
std::ostream &operator<<(std::ostream &os, const std::pair<T, U> p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}
template <typename T>
struct countMap {
    map<T, Int> dict;
    countMap() {
        dict = map<T, Int>();
    }
    Int operator[](T key) {
        if (dict.find(key) != dict.end()) {
            return dict[key];
        } else {
            return 0;
        }
    }
    void incremntFor(T key) {
        if (dict.find(key) != dict.end()) {
            dict[key]++;
        } else {
            dict.emplace(key, 1);
        }
    }
    auto begin() const {
        return dict.begin();
    }
    auto end() const {
        return dict.end();
    }
};
int main() {
    Int n;
    cin >> n;
    auto dict = countMap<Int>();
    Int sum = 0;
    rep(i, n) {
        Int a;
        cin >> a;
        sum += a;
        dict.incremntFor(sum);
    }
    Int ans = 0;
    for (auto p : dict) {
        Int key = p.first;
        Int value = p.second;
        ans += value * (value - 1) / 2;
        if (key == 0) {
            ans += value;
        }
    }
    Puts(ans);
}


Measured memory_bytes: 12800