Fortunately, if you’re a ClickHouse user, you can use the built-in function `largestTriangleThreeBuckets(n)(x, y)`.