题目
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static long calc(long[] num,int max) {
int l = 0;
int r = num.length-1;
long res = 0;
while(l<r) {
while(l<r && num[l]+num[r]>max) {
r--;
}
res+=(r-l);
l++;
}
return res;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int l = sc.nextInt();
int r = sc.nextInt();
sc.nextLine();
long[] num = new long[n];
for(int i=0;i<n;i++)
num[i] = sc.nextLong();
Arrays.sort(num);
//1 2 3
long res1 = calc(num,r);
long res2 = calc(num,l-1);
//找l到r之间的就等价于找r减去(l-1)的
System.out.println(res1-res2);
sc.close();
}
}