#![allow(non_snake_case, unused_imports, unused_must_use)] use std::io::{self, prelude::*}; use std::str; fn main() { let (stdin, stdout) = (io::stdin(), io::stdout()); let mut scan = Scanner::new(stdin.lock()); let mut out = io::BufWriter::new(stdout.lock()); macro_rules! input { ($T: ty) => { scan.token::<$T>() }; ($T: ty, $N: expr) => { (0..$N).map(|_| scan.token::<$T>()).collect::>() }; } let N = input!(usize); let L = input!(isize); let R = input!(isize); let mut A = input!(isize, N); A.sort(); let A = A; let mut ans = 1; for l in 0..N { let mut neg: std::collections::BTreeSet<(isize, usize)> = std::collections::BTreeSet::new(); let mut zer: std::collections::BTreeSet<(isize, usize)> = std::collections::BTreeSet::new(); let mut pos: std::collections::BTreeSet<(isize, usize)> = std::collections::BTreeSet::new(); let a = A[l]; if a < 0 { neg.insert((a, l)); } else if a == 0 { zer.insert((a, l)); } else { pos.insert((a, l)); } if l + 1 < N { let a = A[l + 1]; if a < 0 { neg.insert((a, l + 1)); } else if a == 0 { zer.insert((a, l + 1)); } else { pos.insert((a, l + 1)); } } for r in l + 2..=N { // [l, r) は ok か? let mut cand = std::collections::BTreeSet::new(); let n1 = neg.range(..).next(); match n1 { Some(&(v, i)) => { cand.insert((v, i)); let n2 = neg.range((v, i + 1)..).next(); match n2 { Some(&(v2, i2)) => { cand.insert((v2, i2)); } None => {} } } None => {} } let nn1 = neg.range(..).next_back(); match nn1 { Some(&(v, i)) => { cand.insert((v, i)); let n2 = neg.range(..(v, i)).next_back(); match n2 { Some(&(v2, i2)) => { cand.insert((v2, i2)); } None => {} } } None => {} } let z1 = zer.range(..).next(); match z1 { Some(&(v, i)) => { cand.insert((v, i)); let n2 = zer.range((v, i + 1)..).next(); match n2 { Some(&(v2, i2)) => { cand.insert((v2, i2)); } None => {} } } None => {} } let p1 = pos.range(..).next(); match p1 { Some(&(v, i)) => { cand.insert((v, i)); let n2 = pos.range((v, i + 1)..).next(); match n2 { Some(&(v2, i2)) => { cand.insert((v2, i2)); } None => {} } } None => {} } let pp1 = pos.range(..).next_back(); match pp1 { Some(&(v, i)) => { cand.insert((v, i)); let n2 = pos.range(..(v, i)).next_back(); match n2 { Some(&(v2, i2)) => { cand.insert((v2, i2)); } None => {} } } None => {} } let C = cand.iter().map(|&(k, _)| k).collect::>(); let mut D = vec![]; let length = C.len(); for i in 0..length { for j in i + 1..length { D.push(C[i] * C[j]); } } // eprintln!( // "{}", // C.iter() // .map(|x| x.to_string()) // .collect::>() // .join(" ") // ); D.sort(); let l2 = D.len(); let m = D[0]; let M = D[l2 - 1]; if L <= m && R >= M { ans = std::cmp::max(ans, r - l); } // A[r]を追加する. if r != N { let a = A[r]; if a < 0 { neg.insert((a, r)); } else if a == 0 { zer.insert((a, r)); } else { pos.insert((a, r)); } } } // A[l] を削除する let a = A[l]; if a < 0 { neg.remove(&(a, l)); } else if a == 0 { zer.remove(&(a, l)); } else { pos.remove(&(a, l)); } } writeln!(out, "{}", ans); } struct Scanner { reader: R, buf_str: Vec, buf_iter: str::SplitWhitespace<'static>, } impl Scanner { fn new(reader: R) -> Self { Self { reader, buf_str: vec![], buf_iter: "".split_whitespace(), } } fn token(&mut self) -> T { loop { if let Some(token) = self.buf_iter.next() { return token.parse().ok().expect("Failed parse"); } self.buf_str.clear(); self.reader .read_until(b'\n', &mut self.buf_str) .expect("Failed read"); self.buf_iter = unsafe { let slice = str::from_utf8_unchecked(&self.buf_str); std::mem::transmute(slice.split_whitespace()) } } } }