sum max recursive impl