#K95192. Max Non-Consecutive Activity Days

    ID: 38809 Type: Default 1000ms 256MiB

Max Non-Consecutive Activity Days

Max Non-Consecutive Activity Days

Peter loves to either walk or read each day, and he wants to ensure that he does not repeat the same activity on consecutive days. On sunny days (represented by 1), Peter has two choices: he can either go for a walk or read a book. On rainy days (represented by 0), however, he can only choose to read. Given the weather forecast for n consecutive days as an array, determine the maximum number of days Peter can perform an activity without violating the rule of doing the same activity on two consecutive days.

Mathematically, if n is the number of days, the answer is always n because Peter can always alternate his activities appropriately. For example, on a sunny day, if he walked the previous day, he can choose to read today, and vice versa. On rainy days, his only option is reading, but he can plan his sunny day turns to ensure the activity alternates.

The task is to output the maximum number of days (which will be equal to n in all cases) that Peter can schedule his activities under the given conditions.

The underlying formula can be expressed as:

\(\text{MaxDays} = n\)

inputFormat

The input is given from standard input (stdin) and consists of two lines:

  1. The first line contains a single integer n \( (1 \leq n \leq 10^5) \): the number of days.
  2. The second line contains n space-separated integers, each either 0 (rainy) or 1 (sunny), representing the weather forecast for each day.

outputFormat

Output to standard output (stdout) a single integer, which is the maximum number of days Peter can perform an activity while ensuring no two consecutive days have the same activity.

Since Peter can always schedule an alternating sequence of activities, the output will always be equal to n.

## sample
5
1 0 1 0 1
5