C - Programming Contest Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

問題文

あなたは競技プログラミングのコンテストを何回か開こうとしています。
コンテストを 1 回開くためには、難易度1 から 8 の問題を各 1 問、計 8 問用意する必要があります。

あなたは問題を N 問用意しており、i 番目の問題の難易度は A_i です。
同じ問題を複数のコンテストで使うことはできないとき、用意した N 問を使ってコンテストを最大何回開けますか?

制約

  • 1 \leq N \leq 5 \times 10^5
  • 1 \leq A_i \leq 8
  • 入力は全て整数である

入力

入力は以下の形式で標準入力から与えられる。

N
A_1 \ldots A_N

出力

答えを出力せよ。


入力例 1

10
1 2 3 4 5 5 6 7 8 8

出力例 1

1

例えば 1,2,3,4,5,7,8,9 番目の問題を使うことでコンテストを 1 回行うことができます。


入力例 2

27
3 1 4 1 5 2 6 5 3 5 8 7 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7

出力例 2

2

入力例 3

1
1

出力例 3

0

Problem Statement

You are going to hold a competitive programming contest several times.
Holding a contest requires preparing a total of eight problems: one problem of each difficulty from 1 through 8.

You have prepared N problems, the i-th of which is of difficulty A_i.
If you cannot use the same problem for multiple contests, at most how many contests can you hold with the N problems prepared?

Constraints

  • 1 \leq N \leq 5 \times 10^5
  • 1 \leq A_i \leq 8
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N
A_1 \ldots A_N

Output

Print the answer.


Sample Input 1

10
1 2 3 4 5 5 6 7 8 8

Sample Output 1

1

For example, you can hold one contest with the 1-st, 2-nd, 3-rd, 4-th, 5-th, 7-th, 8-th, and 9-th problems.


Sample Input 2

27
3 1 4 1 5 2 6 5 3 5 8 7 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7

Sample Output 2

2

Sample Input 3

1
1

Sample Output 3

0