#Lutece1037. Destroy room
Destroy room
Migrated from Lutece 1037 Destroy room
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
There are room number from to , and there are at most people in each room. Dave, a leader of all the people, think there is no need using all of those room. so he ask people gathering to some rooms, and destory others.
But he all is a superstitious man. He want the number of people in one room is or .
It will cost need seconds when a person for room go to room , Dave want to know how to arrange it so people will cost as little as possible.
Input
First has one element .
Second line has numbers, indicate the number of people in room.
Output
If there is a way to arrang it, output the tot time people gone cost.
If there is no way to make it match the condition,output -1
.
Samples
5
2 3 1 0 6
7
2
3 2
-1
Resources
The 13th UESTC Programming Contest Preliminary