Little Elephant and Elections

CodeForces - 258B