#include <iostream>
#include <cstdio>
#include <cassert>
#include <functional>
#include <stack>

//===
// LIBRARY SECTION

// #include <stack>
// #include <cassert>
template<class SemiGroup, class OP = std::function<SemiGroup(SemiGroup, SemiGroup)> >
struct SlidingWindow {
    // first:original data, second:sum
    using Stack = std::stack<std::pair<SemiGroup, SemiGroup> >;
    const OP merge;

    Stack front_st, back_st;

    SlidingWindow(const OP &f):merge(f) {};

    inline SemiGroup fold() {
        if (empty()) return SemiGroup(0);
        
        if (front_st.empty()) return back_st.top().second;
        else if (back_st.empty()) return front_st.top().second;
        else return merge(front_st.top().second, back_st.top().second);
    };

    inline void push_front(SemiGroup d) {
        if (front_st.empty()) front_st.emplace(d, d);
        else front_st.emplace(d, merge(d, front_st.top().second));
    };
    inline void push_back(SemiGroup d) {
        if (back_st.empty()) back_st.emplace(d, d);
        else back_st.emplace(d, merge(back_st.top().second, d));
    };

    void pop_front() {
        assert(!empty());

        if (front_st.empty()) {
            Stack buff;
            while (buff.size() + 1 < back_st.size()) {
                buff.push(back_st.top());
                back_st.pop();
            }
            while (!back_st.empty()) {
                push_front(back_st.top().first);
                back_st.pop();
            }
            while (!buff.empty()) {
                push_back(buff.top().first);
                buff.pop();
            }
        }
        front_st.pop();
    };
    void pop_back() {
        assert(!empty());

        if (back_st.empty()) {
            Stack buff;
            while (buff.size() + 1 < front_st.size()) {
                buff.push(front_st.top());
                front_st.pop();
            }
            while (!front_st.empty()) {
                push_back(front_st.top().first);
                front_st.pop();
            }
            while (!buff.empty()) {
                push_front(buff.top().first);
                buff.pop();
            }
        }
        back_st.pop();
    };
    
    inline bool empty() {
        return size() == 0;
    };

    inline size_t size() {
        return front_st.size() + back_st.size();
    };
};
//===

using i64 = long long;
#define _overload(_1, _2, _3, _4, name, ...) name
#define _rep1(Itr, N) _rep3(Itr, 0, N, 1)
#define _rep2(Itr, a, b) _rep3(Itr, a, b, 1)
#define _rep3(Itr, a, b, step) for (i64 Itr = a; (Itr) < b; (Itr) += step)
#define repeat(...) _overload(__VA_ARGS__, _rep3, _rep2, _rep1)(__VA_ARGS__)

#include <iostream>
#include <string>
#include <vector>
using namespace std;
using llong = long long;

llong n;
vector<llong> a;
SlidingWindow<llong> sum([](auto a, auto b){return a + b;});
SlidingWindow<llong> xum([](auto a, auto b){return a ^ b;});

int main() {
    cin >> n;
    a.resize(n);
    repeat(i, n) {
        cin >> a[i];
    }

    llong ans = 0;
    llong l, r;
    l = r = 0;
    while (r <= n && l < n) {
        while (r < n && sum.fold() == xum.fold())  {
            xum.push_back(a[r]);
            sum.push_back(a[r]);
            r++;
        }

        if (sum.fold() != xum.fold() && !sum.empty()) {
            --r;
            sum.pop_back();
            xum.pop_back();
        }

        ans += r - l;
        l++;

        if (!sum.empty()) {
            xum.pop_front();
            sum.pop_front();
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11648