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 mut a: Vec = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); while !a.is_empty() && a[a.len()-1] == 0 { a.pop(); } if a.is_empty() { println!("Yes"); return; } let n = a.len(); if a[n-1] == n && (a[0] == 0 || a[0] == 1) && (1..n-1).filter(|&i| a[i] != i).count() == 0 { println!("Yes"); } else { println!("No"); } }