If you plot out the curve, we can see that the curve is a convex piecewise linear function with kinks at those values. That is the subgradient changes at those points.
Remark:
An alternative way to do this quicker is to note that this is just measuring the sum of distance of $x$ from the points $2$, $-3$ and $6$. It can be proven that the optimal solution is at the median. In this case, the median is $2$ and $2$ would minimize $A$.
subgradient of $|x|$ would be $sign(x)$.
Let's consider what happens when $x \notin \{2, -3, 6 \}.$
When $x < -3$, the subgradient would be $(-1)+(-1)+(-1)=-3<0$, hence it is decreasing.
When $ x \in (-3,2)$, the subgradient would be $1 + (-1)+(-1) = -1<0$, hence it is still decreasing.
when $x \in (2,6)$, the subgradient would be $1+1+(-1)=1 > 0$, hence it is increasing.
when $x > 6$, the subgradient is $1+1+1=3 >0$ and it is increasing.
We can see that the slope changes from negative to positive at the median where there are equal number of kinks of the left and equal number of kinks on the right.
The minimum of $|x-k| = 0$ at $x=k$.
Therefore, the minimum should lie at one of our $k$'s $(-3,2,6)$.
– Saketh Malyala Jun 21 '17 at 01:11