use std::{collections::BinaryHeap, cmp::Reverse}; fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut a = String::new(); std::io::stdin().read_line(&mut a).ok(); let a: Vec = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let mut b = String::new(); std::io::stdin().read_line(&mut b).ok(); let b: Vec = b.trim().split_whitespace().map(|s| s.parse::().unwrap() / 2).collect(); let a = a.into_iter().map(|v| (Reverse(v), Reverse(0))).collect::, Reverse)>>(); let mut result = 0usize; for i in 0..n { let mut pque = a.clone().to_owned(); for j in 0..n { let (level, cnt) = pque.pop().unwrap(); let bidx = if i + j >= n { i + j - n } else { i + j }; pque.push((Reverse(level.0 + b[bidx]), Reverse(cnt.0 + 1))); result = result.max(cnt.0 + 1); } } println!("{}", result); }