added algorithm Andrew monotine chains