#SP0000135. Tập con có tổng từng cặp nguyên tố (Simple Subset)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Tập con có tổng từng cặp nguyên tố (Simple Subset)
Simple Subset
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You are given an array of positive integers; equal values are allowed. Choose a subsequence (not necessarily contiguous) such that the sum of every pair of elements at distinct chosen positions is prime.
Maximize the number of selected elements. Equal values at different positions count as distinct elements. Any maximum-size valid subsequence may be printed.
Input
The first line contains . The second line contains exactly integers .
Output
Print the maximum size on the first line. Print the selected elements separated by spaces on the next line, in any order.
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; for every .
- Subtask 3 (50 points): ; for every .
Examples
Input
3
2 1 1
Output
3
1 1 2
Explanation
The input has three elements . Taking all three works: is prime, and both remaining pairwise sums equal , also prime. There are only three input positions, so the optimum size is 3, represented by 1 1 2.