QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#6220. Anti-prime Sequence

Statistics

Because he has encountered too many problems involving prime numbers, computer scientist JYY has become tired of them.

For a sequence $X: x_1, x_2, \dots, x_L$ of length $L \ge 2$, if for any $1 \le i < j \le L$, the sum $x_i + x_j$ is not a prime number, JYY considers the sequence $X$ to be an "anti-prime sequence."

JYY has a sequence $A: a_1, a_2, \dots, a_N$ of length $N$. He wishes to select a subsequence containing the maximum number of elements such that this subsequence is an anti-prime sequence.

Input

The first line contains a positive integer $N$.

The next line contains $N$ positive integers, describing $a_1, a_2, \dots, a_N$ in order.

Output

Output a single integer representing the length of the longest anti-prime subsequence. It is guaranteed that an anti-prime subsequence exists.

Examples

Input 1

6
1 2 2 3 4 10

Output 1

4

Constraints

For 10% of the data, $N \le 10$;

For 40% of the data, $N \le 150$;

For 80% of the data, $N \le 1000$;

For 100% of the data, $2 \le N \le 3000$, $1 \le a_i \le 10^5$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.