#include<bits/stdc++.h>
using namespace std;
int main() {
unordered_map<int,int> counts;
int n,l,r;
cin>>n>>l>>r;
vector<int> v(n);
for(int i=0;i<n;i++) cin>>v[i];
int a=0,b=-1;
int64_t answer = 0;
while(a<n) {
while(b + 1 < n && counts[v[b+1]] == 0 && b-a+2 <= r) counts[v[++b]]++; // while the next element on the right isn't a duplicate, we move the right pointer
answer += max(0, (b - a + 1) - l + 1);
counts[v[a++]]--;
}
cout<<answer<<endl;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IG1haW4oKSB7CiAgICB1bm9yZGVyZWRfbWFwPGludCxpbnQ+IGNvdW50czsKICAgIGludCBuLGwscjsKICAgIGNpbj4+bj4+bD4+cjsKICAgIHZlY3RvcjxpbnQ+IHYobik7CiAgICBmb3IoaW50IGk9MDtpPG47aSsrKSBjaW4+PnZbaV07CiAgICBpbnQgYT0wLGI9LTE7CiAgICBpbnQ2NF90IGFuc3dlciA9IDA7CiAgICB3aGlsZShhPG4pIHsKICAgICAgICB3aGlsZShiICsgMSA8IG4gJiYgY291bnRzW3ZbYisxXV0gPT0gMCAmJiBiLWErMiA8PSByKSBjb3VudHNbdlsrK2JdXSsrOyAvLyB3aGlsZSB0aGUgbmV4dCBlbGVtZW50IG9uIHRoZSByaWdodCBpc24ndCBhIGR1cGxpY2F0ZSwgd2UgbW92ZSB0aGUgcmlnaHQgcG9pbnRlcgogICAgICAgIGFuc3dlciArPSBtYXgoMCwgKGIgLSBhICsgMSkgLSBsICsgMSk7CiAgICAgICAgY291bnRzW3ZbYSsrXV0tLTsKICAgIH0KICAgIGNvdXQ8PGFuc3dlcjw8ZW5kbDsKCn0=