#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

// mod int struct
// original : https://github.com/beet-aizu/library/blob/master/mod/mint.cpp

struct mint {
    ll v;
    ll mod;
    mint() : v(0) {}
    mint(signed v, ll mod = MOD) : v(v), mod(mod) {}
    mint(ll t, ll mod = MOD) : mod(mod) {
        v = t % mod;
        if (v < 0)
            v += mod;
    }

    mint pow(ll k) {
        mint res(1), tmp(v);
        while (k) {
            if (k & 1)
                res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }

    static mint add_identity() { return mint(0); }
    static mint mul_identity() { return mint(1); }

    mint inv() { return pow(mod - 2); }

    mint &operator+=(mint a) {
        v += a.v;
        if (v >= mod)
            v -= mod;
        return *this;
    }
    mint &operator-=(mint a) {
        v += mod - a.v;
        if (v >= mod)
            v -= mod;
        return *this;
    }
    mint &operator*=(mint a) {
        v = 1LL * v * a.v % mod;
        return *this;
    }
    mint &operator/=(mint a) { return (*this) *= a.inv(); }

    mint operator+(mint a) const { return mint(v) += a; };
    mint operator-(mint a) const { return mint(v) -= a; };
    mint operator*(mint a) const { return mint(v) *= a; };
    mint operator/(mint a) const { return mint(v) /= a; };

    mint operator-() const { return v ? mint(mod - v) : mint(v); }

    bool operator==(const mint a) const { return v == a.v; }
    bool operator!=(const mint a) const { return v != a.v; }
    bool operator<(const mint a) const { return v < a.v; }

    // find x s.t. a^x = b
    static ll log(ll a, ll b) {
        const ll sq = 40000;
        unordered_map<ll, ll> dp;
        dp.reserve(sq);
        mint res(1);
        for (int r = 0; r < sq; r++) {
            if (!dp.count(res.v))
                dp[res.v] = r;
            res *= a;
        }
        mint p = mint(a).inv().pow(sq);
        res    = b;
        for (int q = 0; q <= MOD / sq + 1; q++) {
            if (dp.count(res.v)) {
                ll idx = q * sq + dp[res.v];
                if (idx > 0)
                    return idx;
            }
            res *= p;
        }
        assert(0);
        return ll(-1);
    }

    static mint comb(long long n, int k) {
        mint num(1), dom(1);
        for (int i = 0; i < k; i++) {
            num *= mint(n - i);
            dom *= mint(i + 1);
        }
        return num / dom;
    }
};
ostream &operator<<(ostream &os, mint m) {
    os << m.v;
    return os;
}

template <typename T = ll>
struct SegmentTreeLazyAdd {
  private:
    using F = function<T(T, T)>;
    int n;
    vector<T> node, lazy;
    vector<bool> lazyFlag;
    F func;
    T UNIT;

  public:
    SegmentTreeLazyAdd(int sz, F func, T UNIT) : func(func), UNIT(UNIT) {
        n = 1;
        while (n < sz)
            n *= 2;
        node.assign(2 * n - 1, UNIT);
        lazy.assign(2 * n - 1, UNIT);
        lazyFlag.resize(2 * n - 1, false);
    }
    SegmentTreeLazyAdd(vector<T> v, F func, T UNIT) : func(func), UNIT(UNIT) {
        int sz = int(v.size());
        n      = 1;
        while (n < sz)
            n *= 2;
        node.resize(2 * n - 1, UNIT);
        lazy.resize(2 * n - 1, UNIT);
        lazyFlag.resize(2 * n - 1, false);

        for (int i = 0; i < sz; i++)
            node[i + n - 1] = v[i];
        for (int i = n - 2; i >= 0; i--)
            node[i] = func(node[i * 2 + 1], node[i * 2 + 2]);
    }
    void lazyEvaluate(int k, int l, int r) {
        if (lazyFlag[k]) {
            node[k] += lazy[k];
            if (r - l > 1) {
                lazy[k * 2 + 1] += lazy[k];
                lazy[k * 2 + 2] += lazy[k];
                lazyFlag[k * 2 + 1] = lazyFlag[k * 2 + 2] = true;
            }
            lazyFlag[k] = false;
            lazy[k]     = 0;
        }
    }
    // add x to nodes in [a, b)
    void add(int a, int b, T x, int k = 0, int l = 0, int r = -1) {
        if (r < 0)
            r = n;
        lazyEvaluate(k, l, r);
        if (b <= l || r <= a) {
            return;
        }
        if (a <= l && r <= b) {
            lazy[k] += x; // +=
            lazyFlag[k] = true;
            lazyEvaluate(k, l, r);
            return;
        } else {
            const int mid = (l + r) / 2;
            add(a, b, x, k * 2 + 1, l, mid);
            add(a, b, x, k * 2 + 2, mid, r);
            node[k] = func(node[2 * k + 1], node[2 * k + 2]);
        }
    }
    void update(int k, T a) {
        query(k, k + 1); // probagate lazy nodes
        // leaves are at index n-1 to 2*n-2
        k += n - 1;
        node[k] = a;
        while (k > 0) {
            // k -> parent node
            k = (k - 1) / 2;
            // func(child nodes)
            node[k] = func(node[2 * k + 1], node[2 * k + 2]);
        }
    }
    // get func() in [a, b)
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0)
            r = n;
        lazyEvaluate(k, l, r);
        if (b <= l || r <= a)
            return UNIT;
        if (a <= l && r <= b)
            return node[k];
        T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return func(vl, vr);
    }
};

int main() {
    int n;
    cin >> n;
    deque<ll> a(n);
    ll tot = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        tot ^= a[i];
    }
    if (tot == 0) {
        int na = a.size();
        for (int i = 1; i < na; ++i) {
            a[i] ^= a[i - 1];
        }
        int zero = 0;
        for (int i = 0; i < na; ++i) {
            if (a[i] == 0)
                zero++;
        }
        mint ret = mint(2).pow(zero - 1);
        vector<mint> pos(1 << 22, 0);
        vector<mint> zeros(1 << 22, 1);
        mint UNIT = 0;
        auto f    = [](mint l, mint r) { return l + r; };
        SegmentTreeLazyAdd<mint> seg(1 << 22, f, UNIT);
        for (int i = 0; i < na - 1; ++i) {
            if (a[i] == 0) {
                seg.add(0, 1 << 22, 1);
            } else {
                if (pos[a[i]] == 0) {
                    pos[a[i]] = 1;
                    seg.update(a[i], 0);
                } else {
                    zeros[a[i]] += seg.query(a[i], a[i] + 1) * pos[a[i]];
                    seg.update(a[i], 0);
                    pos[a[i]] += zeros[a[i]];
                }
            }
        }
        for (auto &p : pos) {
            ret += p;
        }
        cout << ret << "\n";
    } else {
        while (a.front() == 0)
            a.pop_front();
        while (a.back() == 0)
            a.pop_back();
        a.push_front(0);
        mint pos  = 0;
        mint zero = 1;
        int na    = a.size();
        for (int i = 1; i < na; ++i) {
            a[i] ^= a[i - 1];
        }
        for (int i = 1; i < na - 1; ++i) {
            if (a[i] == tot) {
                pos += zero;
            } else if (a[i] == 0) {
                zero += pos;
            }
        }
        cout << zero << "\n";
    }

    return 0;
}

Measured memory_bytes: 398592