Problem hidden on 2015-03-12 16:59:18 by Con Bò Huyền Thoại

MTXN2NT1 - XN2NTQ - Judge Subtask 3, 4

For a positive integer n a1, a2, .... an, sought grouped satisfy the following conditions:

- Each number can only be placed in a group;

- Each group has exactly 2 and the total number of two numbers in each group is prime;

- The number of groups are classified as the most.

example: With 8 positive integers 1, 2, 3, 4, 5, 6, 7, 8 have a classified into 4 groups (1,4); (2.5); (3.8); (6.7);

 

Input

- The first line contains an integer N.

- 2nd line contains N integers a1, a2, ... an. (a[i] <= 10^6).

Output

- 1 single line group number to find the most

Example

Input:
8
1 2 3 4 5 6 7 8

Output:
4
Subtask 1: n<=10 [25 tests]
Subtask 2: n<=20 [25 tests]
Subtask 3: n<=1000 [25 tests]
Subtask 4: n <= 10 ^ 5, the numbers a1, a2, .. a[n] is a permutation of 1, 2, ... n [25 tests]
Note: here judge subtask 3, 4! go to MTXN2NTQ to judge substack 1, 2.
http://www.spoj.com/problems/MTXN2NTQ/en/


Được gửi lên bởi:Đặng Minh Tiến
Ngày:2014-12-16
Thời gian chạy:1s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:ASM32-GCC MAWK BC C NCSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D DART ELIXIR FANTOM FORTH GRV JULIA KTLN LUA NODEJS OBJC OCAML OCT PAS-FPC PIKE PROLOG PYPY3 R RACKET CHICKEN ST SQLITE SWIFT UNLAMBDA
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.