LED Display

One day in the laboratory, Fred found some LED displays. This seven-segment LED can display digit 0 to 9 properly. But Fred soon find the LED have a serious problem, at the beginning, the seven bars were all on. But when one bar once was trun off, it can't be turn on again! So ecah LED only can display digit in certain oder. For example, one LED can display 9,3,7 successively, but can't display 2,4.

Now, Fred have a task to display a sequence of digit that is between 0 to 9. Because of the shortcoming of these LEDs, he need a number of them. But he also want to minimize the number, can you help him?

NOTE:If two digits in a sequece are the same,Fred want for the clearness, so he thought the latter digit can't be displayed on the same LED.

Input:

The input consists of several test cases. The first line of each test case contains a positive integer N (<=1000), then followed by a list of N digits. Each digit follows with a blank space.

Output:

For each test case, you must print a minimum number of LED that Fred need in one line.

Sample Input:
1
8

4
9 0 7 3

8
8 8 8 9 6 5 4 1
Sample Output:
1
2 (Hint:one mothod is display {9,3} on the first LED; {0,7} on the second)
3 (Hint:one possible solution is {8},{8,9,4,1},{8,6,5})

http://download.csdn.net/download/tuchunr168/6571463

https://www.baidu.com/baidu.php?sc.JaTK00018BBPWl-uT6TFtlGG06ZWJyne9Ir6XeGYDVsCWoyFlxXMu7_WdBFLhfxZRw0-U1uhhepfBErISlkvTPr8oY55CcTdKun8GCtlFEUZqPaZyimNuMqtsOzI0107pBQA1XDuYhoVi98pJLvUmxqQyt8NiaGKK8Jr1HNLTG93wEBu46.7D_KhUV9JfGyAp7WF8_zU-0.U1Yk0ZDqHDNDFHcswA-1TAk9XfKY5yk-uaRznAwGTLK_mgb0pyYqnWcd0ATqmhNsT100Iybqmh7GuZR0TA-b5HD40APGujYdPfKVIjYknjDLg1DsnH-xn1msnfKopHYs0ZFY5Hc3PsK-pyfqnHf1rNtznHDsPNtkrjRvn7tkP10snNtznW01P-tznWDLnsKBpHYznjwxnHRd0AdW5HnLn1DzrHbsn7tsg100TgKGujYs0Z7Wpyfqn0KzuLw9u1Ys0AqvUjYknj0snzdbX-tknj0knzYkg1DsnjRsQywlg1DsnH03Qywlg1DsnHnvQywlg1DsnH6kQH7xnH0znj6VndtknjndPaYkg1Dsn1TzQHFxnH01rHDVnNtknjn4riYkg1DsPjDvQH7xnH0YnWcVnNtknjfLPidbX-tknjfLridbX-tknjRsPzYkg1DsPHDdQywlg1DznBdbX-tznjInQywlg1csPYkmQywlg1c1nW6VPWT1P-tzPWm4Qywlg1cvPW-mQywlg1ndn1TVP7tYPH6YQywlg1RsPWbVnNtdPjbzQHPxPHT3nBdbX-tdrjn3Qywlg1R4nj6VuZGxPWDYnzYdg1mzrjfVuZGxPWfzPadbX-tvPjnzQH7xPWRkPBdbX-tvPHf1Qywlg1mvnHnVuZGxPWm3radbX-tvPWbkQywlg1mLrHmVuZGxPW6zridbX-tvrjmvQywlg1m4PjRVnNtvrHT3Qywlg16vnaYk0A7B5HKxn0K-ThTqn0KsTjYs0A4vTjYsQW0snj0snj0s0AdYTjYs0AwbUL0qn0KzpWYs0Aw-IWdsmsKhIjYs0ZKC5H00ULnqn0KBI1Ykn0K8IjYs0ZPl5fKYIgnqnHnknj6kn1TvnjRvPH0LnW6dPjT0ThNkIjYkPj64nH0znW6YPW6s0ZPGujdbujfLP10LPj0snj6kuWc10AP1UHYdnWRdwj9jnRPjrDRzPjm40A7W5HD0TA3qn0KkUgfqn0KkUgnqn0KlIjYs0AdWgvuzUvYqn7tsg100uA78IyF-gLK_my4GuZnqn7tsg100uZwGujYs0ANYpyfqQHD0mgPsmvnqn0KdTA-8mvnqn0KkUymqn0KhmLNY5H00uMGC5H00uh7Y5H00XMK_Ignqn0K9uAu_myTqnfKWThnqnWTzP1T&ck=1803.1.94.252.187.247.172.562&shh=www.baidu.com&sht=baidu&us=1.0.1.0.1.297.0.0&ie=utf-8&f=8&tn=baidu&wd=LED%20Display&oq=Ancient%2520Relics&rqlang=cn&inputT=391&bc=110101