下面是代码
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define inf 0x3f3f3f3f3f3f3f3f
#define LOCAL
using namespace std;
namespace ly{
namespace IO{
#ifndef LOCAL
constexpr auto maxn=1<<20;
char in[maxn],out[maxn],*p1=in,*p2=in,*p3=out;
#define getchar()(p1==p2&&(p2=(p1=in)+fread(in,1,maxn,stdin),p1==p2)?EOF:*p1++)
#define flush()(fwrite(out,1,p3-out,stdout))
#define putchar(x)(p3==out+maxn&&(flush(),p3=out),*p3++=(x))
class Flush{public:~Flush(){flush();}}_;
#endif
namespace usr{
template<typename type>
inline type read(type&x){
x=0;bool flag(0);char ch=getchar();
while(!isdigit(ch))flag^=ch=='-',ch=getchar();
while(isdigit(ch))x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
return flag?x=-x:x;
}
template<typename type>
inline void write(type x){
x<0?x=-x,putchar('-'):0;
static short Stack[50],top(0);
do Stack[++top]=x%10,x/=10;while(x);
while(top)putchar(Stack[top--]|48);
}
inline char read(char&x){do x=getchar();while(isspace(x));return x;}
inline char write(const char&x){return putchar(x);}
inline void read(char*x){static char ch;read(ch);do*(x++)=ch;while(!isspace(ch=getchar())&&~ch);}
template<typename type>inline void write(type*x){while(*x)putchar(*(x++));}
inline void read(string&x){static char ch;read(ch),x.clear();do x+=ch;while(!isspace(ch=getchar())&&~ch);}
inline void write(const string&x){for(int i=0,len=x.length();i<len;++i)putchar(x[i]);}
template<typename type,typename...T>inline void read(type&x,T&...y){read(x),read(y...);}
template<typename type,typename...T>
inline void write(const type&x,const T&...y){write(x),putchar(' '),write(y...),sizeof...(y)^1?0:putchar('\n');}
template<typename type>
inline void put(const type&x,bool flag=1){write(x),flag?putchar('\n'):putchar(' ');}
}
#ifndef LOCAL
#undef getchar
#undef flush
#undef putchar
#endif
}
using namespace IO::usr;
}
using namespace ly::IO::usr;
int32_t n,l,r;
int s[100010];
struct tree{
int32_t rt,cnt,t[13600010],ls[13600010],rs[13600010];
void pushup(int32_t p){
t[p]=t[ls[p]]+t[rs[p]];
}
void update(int idx,int32_t&p,int k,int l=-1e10,int r=1e10){
if(!p)p=++cnt;
if(l==r){
t[p]+=k;
return;
}
int mid=(l+r)/2;
if(idx<=mid)update(idx,ls[p],k,l,mid);
else update(idx,rs[p],k,mid+1,r);
pushup(p);
}
int32_t query(int L,int R,int32_t&p,int l=-1e10,int r=1e10){
if(!p)return 0;
if(L<=l&&R>=r){
return t[p];
}
int mid=(l+r)/2,ans=0;
if(L<=mid)ans+=query(L,R,ls[p],l,mid);
if(R>mid)ans+=query(L,R,rs[p],mid+1,r);
return ans;
}
}tr;
signed main(){
read(n,l,r);
for(int32_t a,i=1;i<=n;i++){
read(a);
s[i]=s[i-1]+a;
}
tr.update(s[0],tr.rt,1);
int sum=0;
for(int32_t i=1;i<=n;i++){
sum+=tr.query(s[i]-r,s[i]-l,tr.rt);
tr.update(s[i],tr.rt,1);
}
put(sum);
return 0;
}