Winter Supplies
InterviewTime limit2sMemory limit1024 MB
Given the signed jar numbers left after one jar vanished, find the number on the missing jar, where each absolute value must appear equally often with each sign.
Problem
Kopatych is a kind and thrifty gardener bear who grows food for all the Smeshariki. He usually hibernates in winter, but he always leaves plenty of supplies so the others can get through the cold season without worrying.
This year he counted his food and checked how many jars each product filled. Every product fills an even number of jars. In total there are jars.
He numbered all the jars. Winter lasts two months. Jars for the first month get negative numbers, and jars for the second month get positive numbers. He followed two rules. First, jars holding the same product have numbers with the same absolute value. Second, each product has the same number of jars for the first month and the second month.
This morning he found that one jar had disappeared overnight. From the numbers on the remaining jars, he wants to find the number on the missing jar.
Input
The first line contains an odd integer (), the number of jars Kopatych has left. The second line contains integers (), the numbers on all the remaining jars.
Output
Print one integer, the number written on the missing jar.