Cartesian tree constructed correctly