An elastic-perfectly plastic analysis of the bending of the lithosphere at a trench