spoj#CHARGY. The World of Charges
The World of Charges
In the world of charges there are 3 types of charge. Positive , Negative and neutral. As always if one positive charge comes in touch with another negative charge they share charge and both of them vanishes.
Some charges has become sick today in the world of hospital. So they went to the Hospital of charges for their treatment. Unfortunately, There is a long queue in front of the doctor's room. If any charge wants to meet the doctor , he have to stand in the queue. As normal in the queue a charge comes in contact with the charge right before him and the charge right after him.
The doctor is having a tough day as you can guess. You have the appoinment list of the doctor. Can you determine what is the number of patient he'll have to prescribe today ? Assuming that the charges will come in the queue in the order of their appoinment.
Input
First line of input contains a number n, the number of patient. Here 0<n<=100000;
The next line contains n space separated integers a1 ,a2,a3 ,........,an . where ai=1 if the charge is positive,ai= -1 if the charge is negative and ai=0 if the charge is neutral.
Output
In a single print the number of patient the doctor will have to prescribe.
Example
Input:
5
1 -1 1 0 1
Output:
3
Input:
6
1 -1 -1 1 1 -1
Output:
0