Under construction

Still being built. Things may change

Number Sequence

Time limit1sMemory limit1024 MB

Summary
Given a sequence of 1, 2, 4, and 8, find the longest run of equal adjacent values and count the windows of four consecutive elements that contain all four values.
Level

Easy2 of 10

Topics
Array, Implementation
Solved
No attempts yet

Statement

The number sequence a1,a2,…,aNa_1, a_2, \ldots, a_N consists only of the numbers 1, 2, 4, and 8. Some of these numbers may not appear in the sequence. Write a program seq that answers two questions:

  • What is the length of the longest contiguous subsequence whose elements all have the same value?
  • How many groups of four consecutive elements ai,ai+1,ai+2,ai+3a_i, a_{i+1}, a_{i+2}, a_{i+3} contain all four numbers 1, 2, 4, and 8 in some order?

Input

The first line of standard input contains a positive integer NN, the number of elements in the sequence. The second line contains the NN values of the sequence, separated by single spaces. Each value is 1, 2, 4, or 8.

Output

Print one line to standard output with two integers separated by a single space. The first is the length of the longest run of equal consecutive elements. The second is the number of groups of four consecutive elements that contain all of 1, 2, 4, and 8.

Constraints

4≤N≤100004 \le N \le 10000

Hint

In the example, the longest run of equal adjacent elements is 8, 8, 8, so the first answer is 3. The four groups of consecutive elements that contain all of 1, 2, 4, and 8 are 8, 1, 2, 4; 1, 2, 4, 8; 2, 4, 8, 1; and 4, 8, 1, 2.

Examples1

  1. Example 1

    Input
    11
    4 8 8 8 1 2 4 8 1 2 2
    
    Expected output
    3 4