#P8611. [蓝桥杯 2014 省 AB] 蚂蚁感冒

[蓝桥杯 2014 省 AB] 蚂蚁感冒

Description

There are nn ants on a thin straight rod of length 100100 cm. Some ants are facing left, and some are facing right.

Each ant can only crawl forward along the rod at a speed of 11 cm/s.

When two ants meet, they will both turn around and crawl in the opposite directions.

Among these ants, one ant has caught a flu. When it meets other ants, it will infect the ant it touches.

Please compute how many ants will have the flu when all ants have crawled off the rod.

Input Format

The first line contains an integer n(1<n<50)n(1<n<50), representing the total number of ants.

The next line contains nn integers Xi(100<Xi<100)X_i(-100<X_i<100) separated by spaces. The absolute value of XiX_i indicates the distance from the ant to the left end of the rod. A positive value means the ant is facing right, and a negative value means it is facing left. The input will not contain 00, and no two ants will be at the same position. The ant represented by the first number is the one that has the flu.

Output Format

Output one integer, representing the final number of ants that have the flu.

3
5 -2 8
1
5
-10 8 -20 12 25
3

Hint

Translated by ChatGPT 5