usaco; solve "Broken Necklace" from Chapter 1, Section 1