#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    vector<ll> a(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> a[i];

    ll k1, k2;
    cin >> k1 >> k2;

    vector<ll> start(n + 2, 0);

    // start[k] = number of l>k with a[k]+a[l]>k2
    for (int k = 1; k <= n - 1; k++) {
        int pos = upper_bound(a.begin() + k + 1, a.end(),
                              k2 - a[k]) - a.begin();
        if (pos <= n)
            start[k] = n - pos + 1;
    }

    vector<ll> suffix(n + 3, 0);

    for (int i = n; i >= 1; i--)
        suffix[i] = suffix[i + 1] + start[i];

    ll ans = 0;

    for (int j = 2; j <= n - 2; j++) {

        // number of i<j with a[i]+a[j]>k1
        int pos = upper_bound(a.begin() + 1, a.begin() + j,
                              k1 - a[j]) - a.begin();

        ll left = j - pos;

        ll right = suffix[j + 1];

        ans += left * right;
    }

    cout << ans << '\n';
}