#C9225. Calculate Fitness Score

    ID: 53295 Type: Default 1000ms 256MiB

Calculate Fitness Score

Calculate Fitness Score

You are given a sequence of integers. Your task is to compute the fitness score of the sequence. The fitness score is defined as the length of the longest contiguous subsequence that is either strictly increasing or strictly decreasing.

Note:

  • A single element sequence has a fitness score of 1.
  • Two consecutive numbers are considered strictly increasing if the latter is greater than the former and strictly decreasing if the latter is smaller than the former.

Input/Output Format:

The input is provided via standard input (stdin) and the output should be written to standard output (stdout).

Examples:

Input:
8
1 3 2 4 6 5 8 7

Output: 3

</p>

inputFormat

The first line contains an integer n representing the number of elements in the sequence. The second line contains n space-separated integers which form the sequence.

outputFormat

Output a single integer representing the fitness score of the given sequence. This score is the length of the longest contiguous subsequence that is strictly increasing or strictly decreasing.

## sample
8
1 3 2 4 6 5 8 7
3