Hi :)
We can re-write the function as :
f(x) = 2x - a1 - a2 for x < a1 (positively sloped)
= a1 - a2 for a1 ≤ x ≤ a2 (constant)
= a1 + a2 - 2x for a2 < x (negatively sloped)
Attached is the graph of the function. Clearly, set of maximizers : x ∈ [a1, a2]
Thanks
:)