A wonderful problem that covers almost all topics
I've never seen such an educational problem like 1287C - Гирлянда before.
UPD: Fixed now.