use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let s: Vec = itr.next().unwrap().chars().collect(); // 00 11 1010 0101 for i in 0..n { if (i + 1 < n && s[i] == s[i + 1]) || (i + 3 < n && s[i] == s[i + 2] && s[i + 1] == s[i + 3]) { println!("YES",); return; } } println!("NO",); }