n = int(input())
cost = [0] + [int(item) for item in input().split()]
route = [0] + [int(r) for r in input().split()]
visited = [0] + [False for i in range(n)]
ans = 0
for i in range(1,n+1):
    if visited[i] == True:
        continue

    circle = []
    node = i
    while visited[node] == False:
        visited[node] = True
        circle.append(node)
        node = route[node]
    temp = circle.copy()
    for vertex in temp:
        if vertex == node:
            break
        tmp = circle.pop(0)
    if circle != []:
        ans += min([cost[item] for item in circle])
print(ans)


import sys
input = sys.stdin.readline

class Unionfind:
    def __init__(self, n):
        self.par = [-1]*n
        self.rank = [1]*n

    def root(self, x):
        p = x

        while not self.par[p]<0:
            p = self.par[p]

        while x!=p:
            tmp = x
            x = self.par[x]
            self.par[tmp] = p

        return p

    def unite(self, x, y):
        rx, ry = self.root(x), self.root(y)

        if rx==ry: return False

        if self.rank[rx]<self.rank[ry]:
            rx, ry = ry, rx

        self.par[rx] += self.par[ry]
        self.par[ry] = rx

        if self.rank[rx]==self.rank[ry]:
            self.rank[rx] += 1

    def is_same(self, x, y):
        return self.root(x)==self.root(y)

    def count(self, x):
        return -self.par[self.root(x)]

n = int(input())
c = list(map(int, input().split()))
uf = Unionfind(n)
a = list(map(int, input().split()))

for i in range(n):
    uf.unite(i, a[i]-1)

roots = set(uf.root(i) for i in range(n))
ans = 0

for r in roots:
    cur = r
    s = {r}

    while True:
        nex = a[cur]-1

        if nex in s:
            sta = nex
            break

        s.add(nex)
        cur = nex

    add = c[sta]
    cur = sta

    while True:
        nex = a[cur]-1

        if nex==sta:
            break

        add = min(add, c[nex])
        cur = nex

    ans += add

print(ans)


def dfs(node,edges,costs,visited):
    cycle = False
    visited1 = set()
    while True:
        if node in visited:
            for i in visited1:
                visited.add(i)
            return 0
        if not edges[node]:
            visited1.add(node)
            break
        if node not in visited1:
            visited1.add(node)
            node = edges[node][0]
        else:
            cycle = True
            break

    #print(node,cycle,visited)
    if cycle:
        x = edges[node][0]
        min_cost = costs[x-1]
        while x != node:
            x = edges[x][0]
            min_cost = min(min_cost,costs[x-1])
        cost = min_cost
    else:
        cost = costs[node-1]

    for i in visited1:
        visited.add(i)

    return cost

def solve(zero,edges,costs):
    n = len(costs)
    visited = set()
    cost = 0

    for i in range(1,n+1):
        if i not in visited:
            cost += dfs(i,edges,costs,visited)

    print(cost)

def main():
    n = int(input())
    costs = list(map(int,input().split()))
    mouse = list(map(int,input().split()))
    edges = {}
    for i in range(1,n+1):
        edges[i] = []

    indegree = [0]*(n+1)
    for i in range(1,n+1):
        if i != mouse[i-1]:
            edges[i].append(mouse[i-1])
            indegree[mouse[i-1]] += 1

    zero = []
    for i in range(1,n+1):
        if indegree[i] == 0:
            zero.append(i)

    solve(zero,edges,costs)

main()


def dfs(node,edges,costs,visited):
    cycle = False
    visited1 = set()
    while True:
        if node in visited:
            return 0
        if not edges[node]:
            visited.add(node)
            break
        if node not in visited1:
            visited1.add(node)
            node = edges[node][0]
        else:
            cycle = True
            break

    #print(node,cycle,visited)
    if cycle:
        x = edges[node][0]
        min_cost = costs[x-1]
        while x != node:
            x = edges[x][0]
            min_cost = min(min_cost,costs[x-1])
        cost = min_cost
    else:
        cost = costs[node-1]

    for i in visited1:
        visited.add(i)

    return cost

def solve(zero,edges,costs):
    visited = set()
    cost = 0
    for i in zero:
        if i not in visited:
            #print(i)
            cost += dfs(i,edges,costs,visited)

    print(cost)

def main():
    n = int(input())
    costs = list(map(int,input().split()))
    mouse = list(map(int,input().split()))
    edges = {}
    for i in range(1,n+1):
        edges[i] = []

    indegree = [0]*(n+1)
    for i in range(1,n+1):
        if i != mouse[i-1]:
            edges[i].append(mouse[i-1])
            indegree[mouse[i-1]] += 1

    zero = []
    for i in range(1,n+1):
        if indegree[i] == 0:
            zero.append(i)

    solve(zero,edges,costs)

main()


def dfs(node,edges,costs,visited):
    cycle = False
    visited1 = set()
    while True:
        if node in visited:
            return 0
        if not edges[node]:
            visited.add(node)
            break
        if node not in visited1:
            visited1.add(node)
            node = edges[node][0]
        else:
            cycle = True
            break

    #print(node,cycle,visited)
    if cycle:
        x = edges[node][0]
        min_cost = costs[x-1]
        while x != node:
            x = edges[x][0]
            min_cost = min(min_cost,costs[x-1])
        cost = min_cost
    else:
        cost = costs[node-1]

    for i in visited1:
        visited.add(i)

    return cost

def solve(zero,edges,costs):
    n = len(costs)
    visited = set()
    cost = 0
    for i in zero:
        if i not in visited:
            #print(i)
            cost += dfs(i,edges,costs,visited)

    for i in range(1,n+1):
        if i not in visited:
            cost += dfs(i,edges,costs,visited)

    print(cost)

def main():
    n = int(input())
    costs = list(map(int,input().split()))
    mouse = list(map(int,input().split()))
    edges = {}
    for i in range(1,n+1):
        edges[i] = []

    indegree = [0]*(n+1)
    for i in range(1,n+1):
        if i != mouse[i-1]:
            edges[i].append(mouse[i-1])
            indegree[mouse[i-1]] += 1

    zero = []
    for i in range(1,n+1):
        if indegree[i] == 0:
            zero.append(i)

    solve(zero,edges,costs)

main()


def dfs(node,edges,costs,visited):
    cycle = False
    visited1 = set()
    while True:
        if node in visited:
            return 0
        if not edges[node]:
            visited1.add(node)
            break
        if node not in visited1:
            visited1.add(node)
            node = edges[node][0]
        else:
            cycle = True
            break

    #print(node,cycle,visited)
    if cycle:
        x = edges[node][0]
        min_cost = costs[x-1]
        while x != node:
            x = edges[x][0]
            min_cost = min(min_cost,costs[x-1])
        cost = min_cost
    else:
        cost = costs[node-1]

    for i in visited1:
        visited.add(i)

    return cost

def solve(zero,edges,costs):
    n = len(costs)
    visited = set()
    cost = 0
    for i in zero:
        if i not in visited:
            #print(i)
            cost += dfs(i,edges,costs,visited)

    for i in range(1,n+1):
        if i not in visited:
            cost += dfs(i,edges,costs,visited)

    print(cost)

def main():
    n = int(input())
    costs = list(map(int,input().split()))
    mouse = list(map(int,input().split()))
    edges = {}
    for i in range(1,n+1):
        edges[i] = []

    indegree = [0]*(n+1)
    for i in range(1,n+1):
        if i != mouse[i-1]:
            edges[i].append(mouse[i-1])
            indegree[mouse[i-1]] += 1

    zero = []
    for i in range(1,n+1):
        if indegree[i] == 0:
            zero.append(i)

    solve(zero,edges,costs)

main()


import sys
from array import array  # noqa: F401

def readline(): return sys.stdin.buffer.readline().decode('utf-8')

n = int(input())
cost = (0,) + tuple(map(int, readline().split()))
a = (0,) + tuple(map(int, readline().split()))
deg = [0]*(n+1)
visited = [0]*(n+1)

for d in a[1:]:
    deg[d] += 1

for i in range(1, n+1):
    if visited[i] or deg[i]:
        continue

    v = i
    while deg[v] == 0:
        visited[v] = 1
        deg[a[v]] -= 1
        v = a[v]

ans = 0
for i in range(1, n+1):
    if visited[i]:
        continue

    visited[i] = 1
    v, mincost = a[i], cost[i]
    while v != i:
        visited[v] = 1
        if mincost > cost[v]:
            mincost = cost[v]
        v = a[v]

    ans += mincost

print(ans)


import sys
from array import array  # noqa: F401

def readline(): return sys.stdin.buffer.readline().decode('utf-8')

n = int(readline())
cost = (0,) + tuple(map(int, readline().split()))
a = (0,) + tuple(map(int, readline().split()))
deg = [0]*(n+1)
visited = [0]*(n+1)

for d in a[1:]:
    deg[d] += 1

for i in range(1, n+1):
    if visited[i] or deg[i]:
        continue

    v = i
    while deg[v] == 0:
        visited[v] = 1
        deg[a[v]] -= 1
        v = a[v]

ans = 0
for i in range(1, n+1):
    if visited[i]:
        continue

    visited[i] = 1
    v, mincost = a[i], cost[i]
    while v != i:
        visited[v] = 1
        if mincost > cost[v]:
            mincost = cost[v]
        v = a[v]

    ans += mincost

print(ans)


def kormin(kezd,K,a,c):
    i=kezd
    hal=[kezd]
    K[kezd]=1
    elert=1
    while(K[a[i]]==0 and korben[a[i]]==0):
        K[a[i]]=1
        hal.append(a[i])
        elert=elert+1
        i=a[i]
    minkor=0
    if(korben[a[i]]==0 and a[i] in hal):
        vege=i
        minkor=c[i]
        korben[i]=1
        while(a[i]!=vege):
            korben[a[i]]=1
            if(c[a[i]]<minkor):
                minkor=c[a[i]]
            i=a[i]
    return([elert,minkor])

n=int(input())
c=[]
t=input().split()
for i in range(n):
    c.append(int(t[i]))
a=[]
t=input().split()
for i in range(n):
    a.append(int(t[i])-1)
korben=[]
K=[]
for i in range(n):
    K.append(0)
    korben.append(0)
feldolg=0
osszeg=0
kezd=0
while(feldolg<n):
    while(K[kezd]==1):
        kezd=kezd+1
    x=kormin(kezd,K,a,c)
    feldolg=feldolg+x[0]
    osszeg=osszeg+x[1]
print(osszeg)


import sys
readline = sys.stdin.readline

N = int(readline())
C = list(map(int, readline().split()))
A = list(map(lambda x: int(x)-1, readline().split()))

inf = 10**9
used = set()
ans = 0
for i in range(N):
    if i in used:
        continue
    seen = set()
    stack = [i]
    cnt = 0
    st = None
    while stack:
        vn = stack.pop()
        vf = A[vn]
        if vf in used:
            break
        if vf in seen:
            st = vf
            break
        seen.add(vf)
        stack.append(vf)

    if st is not None:
        vn = st
        cnt = C[vn]
        vf = A[vn]
        vn = A[vn]
        while vn != st:
            cnt = min(cnt, C[vn])
            vn = A[vn]
    used |= seen
    ans += cnt
print(ans)


from sys import stdin
input=lambda : stdin.readline().strip()
from math import ceil,sqrt,factorial,gcd
from collections import deque
def dfs_SCC(at):
	global idno,sccount
	stack.append(at)
	onstack[at]=1
	ids[at]=idno
	low[at]=idno
	visited.add(at)
	idno+=1
	for to in graph[at]:
		if ids[to]==-1:
			dfs_SCC(to)
		if onstack[to]:
			low[at]=min(low[at],low[to])
	if ids[at]==low[at]:
		node=stack.pop()
		while 1:
			onstack[node]=0
			low[node]=ids[at]
			if node==at:
				break
			node=stack.pop()
		sccount+=1
n=int(input())
l=list(map(int,input().split()))
s=list(map(int,input().split()))
graph={i:set() for i in range(1,n+1)}
for i in range(n):
	graph[i+1].add(s[i])
sccount=0
idno=0
onstack=[0 for i in range(n+1)]
ids=[-1 for i in range(n+1)]
low=[-1 for i in range(n+1)]
stack=deque()
unvisited=-1
# print(graph)
visited=set()
for i in range(1,n+1):
	if i not in visited:
		dfs_SCC(i)
	visited.add(i)
# print(sccount)
# print(ids)
# print(low)
ans=0
c={i:set() for i in range(n+1)}
for i in range(1,n+1):
	c[low[i]].add(i)
for i in c:
	if len(c[i])>1:
		mi=float("infinity")
		for k in c[i]:
			mi=min(mi,l[k-1])
		ans+=mi
	elif len(c[i])==1:
		t=0
		for j in c[i]:
			t=j
		if len(graph[t])==1:
			for k in graph[t]:
				if k==t:
					ans+=l[k-1]
print(ans)


from sys import stdin
input=lambda : stdin.readline().strip()
from math import ceil,sqrt,factorial,gcd
from collections import deque
n=int(input())
l=[0]+list(map(int,input().split()))
s=[0]+list(map(int,input().split()))
ans=0
visited=[0]*(n+1)
for i in range(1,n+1):
	x=i
	while visited[x]==0:
		visited[x]=i
		x=s[x]
	if visited[x]!=i:
		continue
	a=x
	mi=l[x]
	while s[x]!=a:
		x=s[x]
		mi=min(mi,l[x])
	ans+=mi
print(ans)


n = int(input())
c = [int(x) for x in input().split()]
c.insert(0,0)
a = [int(x) for x in input().split()]
a.insert(0,0)
done = [0]*(n+1)

sol = 0

for i in range(1,n+1):

    if done[i]==1:
        continue

    cost = 1000000000

    cycle =[0]*(n+1)

    while cycle[i]<2:
        done[i]=1
        cycle[i]+=1
        if (cycle[i]==2 and c[i]<cost):
            cost=c[i]
        i=a[i]

        if done[i]==1 and cycle[i]==0:
            cost=0
            break

    sol+=cost

print(sol)


n = int(input())
c = [int(x) for x in input().split()]
c.insert(0,0)
a = [int(x) for x in input().split()]
a.insert(0,0)

cycles = []
done = []
term_cycles = []

for i in range(1,n+1):

    if i not in done:

        cycle = []
        while i not in cycle and i not in done:
            cycle.append(i)
            done.append(i)
            i = a[i]

            if i in cycle:
                term = cycle[cycle.index(i):]
                term_cycles.append(term)

sol = 0
for cycle in term_cycles:
    sol += min([c[i] for i in cycle])

print(sol)


n = int(input())
c = [int(x) for x in input().split()]
c.insert(0,0)
a = [int(x) for x in input().split()]
a.insert(0,0)
done = [0]*(n+1)

sol = 0

for i in range(1,n+1):

    if done[i]==1:
        continue

    cycle = []

    while i not in cycle and done[i]==0:
        cycle.append(i)
        done[i]=1
        i = a[i]

        if i in cycle:
            term = cycle[cycle.index(i):]
            sol += min([c[j] for j in term])

print(sol)


n = int(input())
c = [int(x) for x in input().split()]
c.insert(0,0)
a = [int(x) for x in input().split()]
a.insert(0,0)

done = [0]*(n+1)
sol = 0
c_i = 0

for i in range(1,n+1):
    c_i+=2
    cost=0

    if done[i]!=0:
        continue

    while done[i]==0:
        done[i]=c_i
        i=a[i]

    if done[i]==c_i:
        # found a new cycle
        cost = c[i]
        while done[i]==c_i:
            done[i]+=1
            i=a[i]
            if c[i]<cost:
                cost=c[i]

    sol+=cost

print(sol)


#include<bits/stdc++.h>

typedef long long LL;
using namespace std;
const int M = 1000000007;
const int N = 2000005;

LL memo[N];

void sieve()
{
LL i,j;

memo[1]=0;
memo[2]=1;

for(i=2;i<N;i++)
	if(memo[i]==1)
		for(j=i+i;j<N;j+=i)
			memo[j]=0;

}

int main()
{LL n,i,j,q=1;

	cin>>n;

vector <LL> v(n);

map <LL,LL> mp;

for(i=0;i<N;i++)
	memo[i]=1;

//for(i=1;i<100;i++)
//	cout<<i<<' '<<memo[i]<<endl;

sieve();

for(i=0;i<n;i++)
	{cin>>v[i];
		mp[v[i]]++;
		if(v[i]!=1 && memo[v[i]+1])
			q=v[i];
	}

if(mp[1]>1)
{
if(q!=1)
	cout<<mp[1]+1<<endl;
else
	cout<<mp[1]<<endl;

for(i=0;i<mp[1];i++)
	cout<<1<<' ';

if(q!=1)
	cout<<q<<endl;
else
	cout<<endl;

return 0;

}
else
{
for(i=0;i<n;i++)
	for(j=i+1;j<n;j++)
		if(memo[v[i]+v[j]])
		{
			cout<<2<<endl<<v[i]<<' '<<v[j]<<endl;
			return 0;
		}

}

cout<<1<<endl<<v[0]<<endl;

}


#include<bits/stdc++.h>

typedef long long LL;
using namespace std;
const int M = 1000000007;
const int N = 2000005;

LL memo[N];

void sieve()
{
LL i,j;

memo[1]=0;
memo[2]=1;

for(i=2;i<N;i++)
	if(memo[i]==1)
		for(j=i+i;j<N;j+=i)
			memo[j]=0;

}

int main()
{LL n,i,j;

	cin>>n;

vector <LL> v(n);

map <LL,LL> mp;

for(i=0;i<N;i++)
	memo[i]=1;

sieve();

//for(i=1;i<20;i++)
//	cout<<i<<' '<<memo[i]<<endl;

for(i=0;i<n;i++)
	{cin>>v[i];
		mp[v[i]]++;
	}

if(mp[1]>1)
{
if(mp[2]>0)
	cout<<mp[1]+1<<endl;
else
	cout<<mp[1]<<endl;

for(i=0;i<mp[1];i++)
	cout<<1<<' ';

if(mp[2]>0)
	cout<<2<<endl;
else
	cout<<endl;

return 0;
}
else
{
for(i=0;i<n;i++)
	for(j=i+1;j<n;j++)
		if(memo[v[i]+v[j]])
		{
			cout<<2<<endl<<v[i]<<' '<<v[j]<<endl;
			return 0;
		}

}

cout<<1<<endl<<v[0]<<endl;

}


#include <bits/stdc++.h>
using namespace std;
int n,a[1001],saceri[2000001],prime[2000001],np,i,j,f,x,y;
vector<int>v;
bool check (int k)
{
if (k==1)
return false;
int i,j;
for (i=1;prime[i]*prime[i]<=k && i<=np;i++)
if (k%prime[i]==0)
return false;
return true;
}
int main()
{
cin>>n;
for (i=2;i*i<=2000000;i++)
if (saceri[i]==0)
for (j=i*i;j<=2000000;j+=i)
saceri[j]=1;
for (i=2;i<=2000000;i++)
if (saceri[i]==0)
prime[++np]=i;
for (i=1;i<=n;i++){
cin>>a[i];
if (a[i]==1)
f++;
}
if (f==0){
for (i=0;i<=n;i++)
for (j=i+1;j<=n;j++)
if (i!=j && check(a[i]+a[j])){
if (i!=0){
cout<<a[i]<<" "<<a[j]<<endl;
return 0;
}
x=a[j];
}
if (x==0){
    cout<<1<<" "<<a[1]<<endl;
    return 0;
}
cout<<x<<endl;
return 0;
}
if (f>=2){
for (i=1;i<=n;i++)
if (check(a[i]+1))
cout<<a[i]<<" ";
return 0;
}

for (i=0;i<=n;i++)
for (j=i+1;j<=n;j++)
if (i!=j && check(a[i]+a[j])){
if (i!=0){
x=a[i];
y=a[j];
break;
}
if (x==0)
x=a[i];
}
if (x==0){
    cout<<1<<" "<<a[1]<<endl;
    return 0;
}
cout<<x<<" ";
if (y>0)
cout<<y<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,a[1001],saceri[2000001],prime[2000001],np,i,j,f,x,y;
vector<int>v;
bool check (int k)
{
if (k==1)
return false;
int i,j;
for (i=1;prime[i]*prime[i]<=k && i<=np;i++)
if (k%prime[i]==0)
return false;
return true;
}
int main()
{
cin>>n;
for (i=2;i*i<=2000000;i++)
if (saceri[i]==0)
for (j=i*i;j<=2000000;j+=i)
saceri[j]=1;
for (i=2;i<=2000000;i++)
if (saceri[i]==0)
prime[++np]=i;
for (i=1;i<=n;i++){
cin>>a[i];
if (a[i]==1)
f++;
}
if (f==0){
for (i=0;i<=n;i++)
for (j=i+1;j<=n;j++)
if (i!=j && check(a[i]+a[j])){
if (i!=0){
cout<<a[i]<<" "<<a[j]<<endl;
return 0;
}
x=a[j];
}
cout<<x<<endl;
return 0;
}
if (f>=2){
for (i=1;i<=n;i++)
if (check(a[i]+1))
cout<<a[i]<<" ";
return 0;
}

for (i=0;i<=n;i++)
for (j=i+1;j<=n;j++)
if (i!=j && check(a[i]+a[j])){
if (i!=0){
x=a[i];
y=a[j];
break;
}
if (x==0)
x=a[i];
}
cout<<x<<" ";
if (y>0)
cout<<y<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,a[1001],saceri[2000001],prime[2000001],np,i,j,f,x,y;
vector<int>v;
bool check (int k)
{
if (k==1)
return false;
int i,j;
for (i=1;prime[i]*prime[i]<=k && i<=np;i++)
if (k%prime[i]==0)
return false;
return true;
}
int main()
{
cin>>n;
for (i=2;i*i<=2000000;i++)
if (saceri[i]==0)
for (j=i*i;j<=2000000;j+=i)
saceri[j]=1;
for (i=2;i<=2000000;i++)
if (saceri[i]==0)
prime[++np]=i;
for (i=1;i<=n;i++){
cin>>a[i];
if (a[i]==1)
f++;
}
if (f==0){
for (i=0;i<=n;i++)
for (j=i+1;j<=n;j++)
if (i!=j && check(a[i]+a[j])){
if (i!=0){
    cout<<2<<endl;
cout<<a[i]<<" "<<a[j]<<endl;
return 0;
}
x=a[j];
}
if (x==0){
    cout<<2<<endl;
    cout<<1<<" "<<a[1]<<endl;
    return 0;
}
cout<<1<<endl;
cout<<x<<endl;
return 0;
}
vector<int>v1;
if (f>=2){
for (i=1;i<=n;i++)
if (check(a[i]+1))
v1.push_back(a[i]);
cout<<v1.size()<<endl;
for (i=0;i<v1.size();i++)
cout<<v1[i]<<" ";
return 0;
}

for (i=0;i<=n;i++)
for (j=i+1;j<=n;j++)
if (i!=j && check(a[i]+a[j])){
if (i!=0){
x=a[i];
y=a[j];
break;
}
if (x==0)
x=a[i];
}
if (x==0){
    cout<<2<<endl;
    cout<<1<<" "<<a[1]<<endl;
    return 0;
}
if (y>0)
cout<<2<<endl;
else
cout<<1<<endl;
cout<<x<<" ";
if (y>0)
cout<<y<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,a[1001],saceri[2000001],prime[2000001],np,i,j,f,x,y;
vector<int>v;
bool check (int k)
{
if (k==1)
return false;
int i,j;
for (i=1;prime[i]*prime[i]<=k && i<=np;i++)
if (k%prime[i]==0)
return false;
return true;
}
int main()
{

cin>>n;
for (i=2;i*i<=2000000;i++)
if (saceri[i]==0)
for (j=i*i;j<=2000000;j+=i)
saceri[j]=1;
for (i=2;i<=2000000;i++)
if (saceri[i]==0)
prime[++np]=i;
for (i=1;i<=n;i++){
cin>>a[i];
if (a[i]==1)
f++;
}
if (f==0){
for (i=0;i<=n;i++)
for (j=i+1;j<=n;j++)
if (i!=j && check(a[i]+a[j])){
if (i!=0){
    cout<<2<<endl;
cout<<a[i]<<" "<<a[j]<<endl;
return 0;
}
x=a[j];
}
if (x==0){
    cout<<2<<endl;
    cout<<1<<" "<<a[1]<<endl;
    return 0;
}
cout<<1<<endl;
cout<<x<<endl;
return 0;
}
vector<int>v1;
if (f>=2){
for (i=1;i<=n;i++)
if (a[i]==1)
v1.push_back(a[i]);
for (i=1;i<=n;i++)
if (a[i]>1 && check(a[i]+1)){
    v1.push_back(a[i]);
    break;
}
cout<<v1.size()<<endl;
for (i=0;i<v1.size();i++)
cout<<v1[i]<<" ";
return 0;
}

for (i=0;i<=n;i++)
for (j=i+1;j<=n;j++)
if (i!=j && check(a[i]+a[j])){
if (i!=0){
x=a[i];
y=a[j];
break;
}
if (x==0)
x=a[i];
}
if (x==0){
    cout<<2<<endl;
    cout<<1<<" "<<a[1]<<endl;
    return 0;
}
if (y>0)
cout<<2<<endl;
else
cout<<1<<endl;
cout<<x<<" ";
if (y>0)
cout<<y<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,a[1001],saceri[2000001],prime[2000001],np,i,j,f,x,y;
vector<int>v;
bool check (int k)
{
if (k==1)
return false;
int i,j;
for (i=1;prime[i]*prime[i]<=k && i<=np;i++)
if (k%prime[i]==0)
return false;
return true;
}
int main()
{
cin>>n;
for (i=2;i*i<=2000000;i++)
if (saceri[i]==0)
for (j=i*i;j<=2000000;j+=i)
saceri[j]=1;
for (i=2;i<=2000000;i++)
if (saceri[i]==0)
prime[++np]=i;
for (i=1;i<=n;i++){
cin>>a[i];
if (a[i]==1)
f++;
}
if (f==0){
for (i=0;i<=n;i++)
for (j=i+1;j<=n;j++)
if (i!=j && check(a[i]+a[j])){
if (i!=0){
    cout<<2<<endl;
cout<<a[i]<<" "<<a[j]<<endl;
return 0;
}
x=a[j];
}
if (x==0){
    cout<<2<<endl;
    cout<<1<<" "<<a[1]<<endl;
    return 0;
}
cout<<1<<endl;
cout<<x<<endl;
return 0;
}
vector<int>v1;
if (f>=2){
for (i=1;i<=n;i++)
if (a[i]==1)
v1.push_back(a[i]);
for (i=1;i<=n;i++)
if (a[i]>1 && check(a[i]+1)){
    v1.push_back(a[i]);
    break;
}
cout<<v1.size()<<endl;
for (i=0;i<v1.size();i++)
cout<<v1[i]<<" ";
return 0;
}

for (i=0;i<=n;i++)
for (j=i+1;j<=n;j++)
if (i!=j && check(a[i]+a[j])){
if (i!=0){
x=a[i];
y=a[j];
break;
}
if (x==0)
x=a[i];
}
if (x==0){
    cout<<2<<endl;
    cout<<1<<" "<<a[1]<<endl;
    return 0;
}
if (y>0)
cout<<2<<endl;
else
cout<<1<<endl;
cout<<x<<" ";
if (y>0)
cout<<y<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,a[1001],saceri[2000001],prime[2000001],np,i,j,f,x,y;
vector<int>v;
bool check (int k)
{
if (k==1)
return false;
int i,j;
for (i=1;prime[i]*prime[i]<=k && i<=np;i++)
if (k%prime[i]==0)
return false;
return true;
}
int main()
{
cin>>n;
for (i=2;i*i<=2000000;i++)
if (saceri[i]==0)
for (j=i*i;j<=2000000;j+=i)
saceri[j]=1;
for (i=2;i<=2000000;i++)
if (saceri[i]==0)
prime[++np]=i;
for (i=1;i<=n;i++){
cin>>a[i];
if (a[i]==1)
f++;
}
if (f==0){
for (i=0;i<=n;i++)
for (j=i+1;j<=n;j++)
if (i!=j && check(a[i]+a[j])){
if (i!=0){
    cout<<2<<endl;
cout<<a[i]<<" "<<a[j]<<endl;
return 0;
}
x=a[j];
}
if (x==0){
    cout<<1<<endl;
    cout<<a[1]<<endl;
    return 0;
}
cout<<1<<endl;
cout<<x<<endl;
return 0;
}
vector<int>v1;
if (f>=2){
for (i=1;i<=n;i++)
if (a[i]==1)
v1.push_back(a[i]);
for (i=1;i<=n;i++)
if (a[i]>1 && check(a[i]+1)){
    v1.push_back(a[i]);
    break;
}
cout<<v1.size()<<endl;
for (i=0;i<v1.size();i++)
cout<<v1[i]<<" ";
return 0;
}

for (i=0;i<=n;i++)
for (j=i+1;j<=n;j++)
if (i!=j && check(a[i]+a[j])){
if (i!=0){
x=a[i];
y=a[j];
break;
}
if (x==0)
x=a[j];
}
if (x==0){
    cout<<1<<endl;
    cout<<a[1]<<endl;
    return 0;
}
if (y>0)
cout<<2<<endl;
else
cout<<1<<endl;
cout<<x<<" ";
if (y>0)
cout<<y<<endl;
return 0;
}


#include <stdio.h>
#include <math.h>
#include <string.h>
void isprime();
int p[2000005];
int num[1005];
int ans[5];
int main()
{
    int n, flag = 1, f = 1;
    int cnt = 0;
    isprime(); p[2] = 1;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &num[i]);
        if(num[i] == 1) cnt++;
    }
    if(cnt > 1) {
        for(int i = 0; i < n; i++)
            if(num[i] != 1 && p[num[i] + 1] == 1)
            {
                printf("%d\n%d", cnt + 1, num[i]);
                f = 0; break;
            }
        if(f){
            printf("%d\n", cnt);
            for(int i = 0; i < cnt - 1; i++)
                printf("1 ");
            printf("1\n");
        }
        else {
            for(int i = 0; i < cnt; i++)
                printf(" 1");
            printf("\n");
        }
    }
    else {
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < n; j++)
            {
                if(i != j && p[num[i] + num[j]] == 1)
                {
                    ans[0] = num[i];
                    ans[1] = num[j];
                    flag = 0;
                    break;
                }
            }
        }
        if(flag) printf("1\n%d\n", num[0]);
        else printf("2\n%d %d\n", ans[0], ans[1]);
    }
    return 0;
}
void isprime()
{
    for(int i = 3; i < 2000005; i++)
    {
        int f = 1;
        for(int j = 2; j <= (int)sqrt((double)i) + 1; j++)
            if(i % j == 0) {f = 0; break;}
        if(f) p[i] = 1;
    }
}


#include <stdio.h>
#include <math.h>
#include <string.h>
void isprime();
int p[1000005];
int num[1005];
int ans[5];
int main()
{
    int n, flag = 1, f = 1;
    int cnt = 0;
    isprime(); p[2] = 1;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &num[i]);
        if(num[i] == 1) cnt++;
    }
    if(cnt > 1) {
        for(int i = 0; i < n; i++)
            if(num[i] != 1 && p[num[i] + 1] == 1)
            {
                printf("%d\n%d", cnt + 1, num[i]);
                f = 0; break;
            }
        if(f){
            printf("%d\n", cnt);
            for(int i = 0; i < cnt - 1; i++)
                printf("1 ");
            printf("1\n");
        }
        else {
            for(int i = 0; i < cnt; i++)
                printf(" 1");
            printf("\n");
        }
    }
    else {
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < n; j++)
            {
                if(i != j && p[num[i] + num[j]] == 1)
                {
                    ans[0] = num[i];
                    ans[1] = num[j];
                    flag = 0;
                    break;
                }
            }
        }
        if(flag) printf("1\n%d\n", num[0]);
        else printf("2\n%d %d\n", ans[0], ans[1]);
    }
    return 0;
}
void isprime()
{
    for(int i = 3; i < 1000005; i++)
    {
        int f = 1;
        for(int j = 2; j <= (int)sqrt((double)i) + 1; j++)
            if(i % j == 0) {f = 0; break;}
        if(f) p[i] = 1;
    }
}


#include <stdio.h>
#include <math.h>
#include <string.h>
bool isprime(int);
int num[1005];
int ans[5];
int main()
{
    int n, flag = 1, f = 1;
    int cnt = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &num[i]);
        if(num[i] == 1) cnt++;
    }
    if(cnt > 1) {
        for(int i = 0; i < n; i++)
            if(num[i] != 1 && isprime(num[i] + 1))
            {
                printf("%d\n%d", cnt + 1, num[i]);
                f = 0; break;
            }
        if(f){
            printf("%d\n", cnt);
            for(int i = 0; i < cnt - 1; i++)
                printf("1 ");
            printf("1\n");
        }
        else {
            for(int i = 0; i < cnt; i++)
                printf(" 1");
            printf("\n");
        }
    }
    else {
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < n; j++)
            {
                if(i != j && isprime(num[i] + num[j]))
                {
                    ans[0] = num[i];
                    ans[1] = num[j];
                    flag = 0;
                    break;
                }
            }
        }
        if(flag) printf("1\n%d\n", num[0]);
        else printf("2\n%d %d\n", ans[0], ans[1]);
    }
    return 0;
}
bool isprime(int n)
{
    for(int i = 2; i <= (int)sqrt((double)n) + 1; i++)
        if(n % i == 0) return 0;
    return 1;
}


#include <stdio.h>
#include <string.h>
bool isprime(int);
int num[1005];
int ans[5];
int main()
{
    int n, flag = 1, f = 1, tmp;
    int cnt = 0, cnt1 = 0, cnt2 = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &num[i]);
        if(num[i] == 1) cnt1++;
        else if(num[i] == 2) cnt2++;
        else cnt++;
    }
    if(cnt == 0 && cnt2 == 1)
    {
        printf("%d\n", cnt1 + cnt2);
        for(int i = 0; i < cnt1; i++)
            printf("1 ");
        printf("2\n");
    }
    else {
        for(int i = 0; i < n; i++)
        {
            if(f && isprime(num[i]) == 1) { tmp = num[i]; f = 0; }
            for(int j = 0; j < n; j++)
            {
                if(i != j && isprime(num[i] + num[j]) == 1)
                {
                    ans[0] = num[i];
                    ans[1] = num[j];
                    flag = 0;
                    break;
                }
            }
        }
        if(flag) printf("1\n%d\n", tmp);
        else printf("2\n%d %d\n", ans[0], ans[1]);
    }
    return 0;
}
bool isprime(int n)
{
    for(int i = 2; i <= n / 2; i++)
        if(n % i == 0) return 0;
    return 1;
}


#include <stdio.h>
#include <string.h>
bool isprime(int);
int num[1005];
int ans[5];
int main()
{
    int n, flag = 1, f = 1;
    int cnt = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &num[i]);
        if(num[i] == 1) cnt++;
    }
    if(cnt > 1) {
        for(int i = 0; i < n; i++)
            if(num[i] != 1 && isprime(num[i] + 1))
            {
                printf("%d\n%d", cnt + 1, num[i]);
                f = 0; break;
            }
        if(f){
            printf("%d\n", cnt);
            for(int i = 0; i < cnt - 1; i++)
                printf("1 ");
            printf("1\n");
        }
        else {
            for(int i = 0; i < cnt; i++)
                printf(" 1");
            printf("\n");
        }
    }
    else {
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < n; j++)
            {
                if(i != j && isprime(num[i] + num[j]))
                {
                    ans[0] = num[i];
                    ans[1] = num[j];
                    flag = 0;
                    break;
                }
            }
        }
        if(flag) printf("1\n%d\n", num[0]);
        else printf("2\n%d %d\n", ans[0], ans[1]);
    }
    return 0;
}
bool isprime(int n)
{
    for(int i = 2; i <= sqrt(n) + 1; i++)
        if(n % i == 0) return 0;
    return 1;
}


#include <stdio.h>
#include <string.h>
bool isprime(int);
int num[1005];
int ans[5];
int main()
{
    int n, flag = 1, f = 1;
    int cnt = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &num[i]);
        if(num[i] == 1) cnt++;
    }
    if(cnt > 1) {
        for(int i = 0; i < n; i++)
            if(num[i] != 1 && isprime(num[i] + 1))
            {
                printf("%d\n%d", cnt + 1, num[i]);
                f = 0; break;
            }
        if(f){
            printf("%d\n", cnt);
            for(int i = 0; i < cnt - 1; i++)
                printf("1 ");
            printf("1\n");
        }
        else {
            for(int i = 0; i < cnt; i++)
                printf(" 1");
            printf("\n");
        }
    }
    else {
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < n; j++)
            {
                if(i != j && isprime(num[i] + num[j]))
                {
                    ans[0] = num[i];
                    ans[1] = num[j];
                    flag = 0;
                    break;
                }
            }
        }
        if(flag) printf("1\n%d\n", num[0]);
        else printf("2\n%d %d\n", ans[0], ans[1]);
    }
    return 0;
}
bool isprime(int n)
{
    for(int i = 2; i <= n / 2; i++)
        if(n % i == 0) return 0;
    return 1;
}


#include <stdio.h>
#include <string.h>
bool isprime(int);
int num[1005];
int ans[5];
int main()
{
    int n, flag = 1, f = 1, tmp;
    int cnt = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &num[i]);
        if(num[i] == 1) cnt++;
    }
    if(cnt > 1) {
        for(int i = 0; i < n; i++)
            if(num[i] != 1 && isprime(num[i] + 1))
            {
                printf("%d\n%d", cnt + 1, num[i]);
                f = 0; break;
            }
        if(f){
            printf("%d\n", cnt);
            for(int i = 0; i < cnt - 1; i++)
                printf("1 ");
            printf("1\n");
        }
        else {
            for(int i = 0; i < cnt; i++)
                printf(" 1");
            printf("\n");
        }
    }
    else {
        for(int i = 0; i < n; i++)
        {
            if(f && isprime(num[i]) == 1) { tmp = num[i]; f = 0; }
            for(int j = 0; j < n; j++)
            {
                if(i != j && isprime(num[i] + num[j]))
                {
                    ans[0] = num[i];
                    ans[1] = num[j];
                    flag = 0;
                    break;
                }
            }
        }
        if(flag) printf("1\n%d\n", tmp);
        else printf("2\n%d %d\n", ans[0], ans[1]);
    }
    return 0;
}
bool isprime(int n)
{
    for(int i = 2; i <= n / 2; i++)
        if(n % i == 0) return 0;
    return 1;
}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
using namespace std;
bool f[1000002];
bool prime(int x){
	return f[x];
}
int main(){
	memset(f, 1, sizeof(f));
	f[0]=0;f[1]=0;
	for (int i = 2; i <= 1000001; i++)
		for (int j = 2; i * j <= 1000001; j++)
			f[i*j]=0;
	int n, a[10001];
	cin >> n;
	bool flag =0;
	for (int i= 1;i<=n;i++) cin>>a[i];
	int tmp = 0,j=0;
	for (int i = 1;i<=n;i++) if (a[i]==1) tmp++;
	for (int i=1;i<=n;i++) if ((tmp>0)&&(a[i]!=1)&&(prime(1+a[i]))){
		flag = 1;
		j=i;
		break;
	}
	if (flag){
		cout<<tmp+1<<endl;
		for (int i=1;i<=tmp;i++) cout<<1<<" ";
		cout<<a[j]<<endl;
	}
	else if (tmp>=2){
				cout<<tmp<<endl;
		for (int i=1;i<=tmp;i++) cout<<1<<" ";
		cout<<endl;
	}
	else{
	for (int i=1;i<=n;i++){
		if (flag) break;
		for (int j=1;j<i;j++){
			if (flag) break;
			if (prime(a[i]+a[j])){
				cout<<2<<endl<<a[i]<<" "<<a[j]<<endl;
				flag=1;
			}
		}
	}
	if (!flag) cout<<1<<endl<<a[1]<<endl;
}
	return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
using namespace std;
bool prime(int x){
	int flag = 1;
	for (int i = 2; i <= sqrt(x); i++)
		if (x % i == 0){
			flag = 0;
			break;
		}
	return flag;
}
int main(){
	int n, a[10000];
	cin >> n;
	bool flag =0;
	for (int i= 1;i<=n;i++) cin>>a[i];
	int tmp = 0,j=0;
	for (int i = 1;i<=n;i++) if (a[i]==1) tmp++;
	for (int i=1;i<=n;i++) if ((tmp>0)&&(a[i]!=1)&&(prime(1+a[i]))){
		flag = 1;
		j=i;
		break;
	}
	if (flag){
		for (int i=1;i<=tmp;i++) cout<<1<<" ";
		cout<<a[j]<<endl;
	}
	else{
	for (int i=1;i<=n;i++){
		if (flag) break;
		for (int j=1;j<i;j++){
			if (flag) break;
			if (prime(a[i]+a[j])){
				cout<<2<<endl<<a[i]<<" "<<a[j]<<endl;
				flag=1;
			}
		}
	}
	if (!flag) cout<<1<<endl<<a[1]<<endl;
}
	return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
using namespace std;
bool prime(int x){
	int flag = 1;
	if (x==1) return 0;
	if (x==0) return 0;
	for (int i = 2; i <= sqrt(x); i++)
		if (x % i == 0){
			flag = 0;
			break;
		}
	return flag;
}
int main(){
	int n, a[10001];
	cin >> n;
	bool flag =0;
	for (int i= 1;i<=n;i++) cin>>a[i];
	int tmp = 0,j=0;
	for (int i = 1;i<=n;i++) if (a[i]==1) tmp++;
	for (int i=1;i<=n;i++) if ((tmp>0)&&(a[i]!=1)&&(prime(1+a[i]))){
		flag = 1;
		j=i;
		break;
	}
	if (flag){
		cout<<tmp+1<<endl;
		for (int i=1;i<=tmp;i++) cout<<1<<" ";
		cout<<a[j]<<endl;
	}
	else if (tmp>=2){
				cout<<tmp<<endl;
		for (int i=1;i<=tmp;i++) cout<<1<<" ";
		cout<<endl;
	}
	else{
	for (int i=1;i<=n;i++){
		if (flag) break;
		for (int j=1;j<i;j++){
			if (flag) break;
			if (prime(a[i]+a[j])){
				cout<<2<<endl<<a[i]<<" "<<a[j]<<endl;
				flag=1;
			}
		}
	}
	if (!flag) cout<<1<<endl<<a[1]<<endl;
}
	return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
using namespace std;
bool f[1000001];
bool prime(int x){
	return f[x];
}
int main(){
	memset(f, 1, sizeof(f));
	f[0]=0;f[1]=0;
	for (int i = 2; i <= 1000001; i++)
		for (int j = 2; i * j <= 1000001; j++)
			f[i*j]=0;
	int n, a[10001];
	cin >> n;
	bool flag =0;
	for (int i= 1;i<=n;i++) cin>>a[i];
	int tmp = 0,j=0;
	for (int i = 1;i<=n;i++) if (a[i]==1) tmp++;
	for (int i=1;i<=n;i++) if ((tmp>0)&&(a[i]!=1)&&(prime(1+a[i]))){
		flag = 1;
		j=i;
		break;
	}
	if (flag){
		cout<<tmp+1<<endl;
		for (int i=1;i<=tmp;i++) cout<<1<<" ";
		cout<<a[j]<<endl;
	}
	else if (tmp>=2){
				cout<<tmp<<endl;
		for (int i=1;i<=tmp;i++) cout<<1<<" ";
		cout<<endl;
	}
	else{
	for (int i=1;i<=n;i++){
		if (flag) break;
		for (int j=1;j<i;j++){
			if (flag) break;
			if (prime(a[i]+a[j])){
				cout<<2<<endl<<a[i]<<" "<<a[j]<<endl;
				flag=1;
			}
		}
	}
	if (!flag) cout<<1<<endl<<a[1]<<endl;
}
	return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
using namespace std;
bool prime(int x){
	int flag = 1;
	for (int i = 2; i <= sqrt(x); i++)
		if (x % i == 0){
			flag = 0;
			break;
		}
	return flag;
}
int main(){
	int n, a[10000];
	cin >> n;
	bool flag =0;
	for (int i= 1;i<=n;i++) cin>>a[i];
	int tmp = 0,j=0;
	for (int i = 1;i<=n;i++) if (a[i]==1) tmp++;
	for (int i=1;i<=n;i++) if ((tmp>0)&&(a[i]!=1)&&(prime(1+a[i]))){
		flag = 1;
		j=i;
		break;
	}
	if (flag){
		cout<<tmp+1<<endl;
		for (int i=1;i<=tmp;i++) cout<<1<<" ";
		cout<<a[j]<<endl;
	}
	else if (tmp>=2){
				cout<<tmp<<endl;
		for (int i=1;i<=tmp;i++) cout<<1<<" ";
		cout<<endl;
	}
	else{
	for (int i=1;i<=n;i++){
		if (flag) break;
		for (int j=1;j<i;j++){
			if (flag) break;
			if (prime(a[i]+a[j])){
				cout<<2<<endl<<a[i]<<" "<<a[j]<<endl;
				flag=1;
			}
		}
	}
	if (!flag) cout<<1<<endl<<a[1]<<endl;
}
	return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
using namespace std;
bool f[2000002];
bool prime(int x){
	return f[x];
}
int main(){
	memset(f, 1, sizeof(f));
	f[0]=0;f[1]=0;
	for (int i = 2; i <= 2000001; i++)
		for (int j = 2; i * j <= 2000001; j++)
			f[i*j]=0;
	int n, a[10001];
	cin >> n;
	bool flag =0;
	for (int i= 1;i<=n;i++) cin>>a[i];
	int tmp = 0,j=0;
	for (int i = 1;i<=n;i++) if (a[i]==1) tmp++;
	for (int i=1;i<=n;i++) if ((tmp>0)&&(a[i]!=1)&&(prime(1+a[i]))){
		flag = 1;
		j=i;
		break;
	}
	if (flag){
		cout<<tmp+1<<endl;
		for (int i=1;i<=tmp;i++) cout<<1<<" ";
		cout<<a[j]<<endl;
	}
	else if (tmp>=2){
				cout<<tmp<<endl;
		for (int i=1;i<=tmp;i++) cout<<1<<" ";
		cout<<endl;
	}
	else{
	for (int i=1;i<=n;i++){
		if (flag) break;
		for (int j=1;j<i;j++){
			if (flag) break;
			if (prime(a[i]+a[j])){
				cout<<2<<endl<<a[i]<<" "<<a[j]<<endl;
				flag=1;
			}
		}
	}
	if (!flag) cout<<1<<endl<<a[1]<<endl;
}
	return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
using namespace std;
bool prime(int x){
	int flag = 1;
	if (x==1) return 0;
	if (x==0) return 0;
	for (int i = 2; i <= sqrt(x); i++)
		if (x % i == 0){
			flag = 0;
			break;
		}
	return flag;
}
int main(){
	int n, a[10000];
	cin >> n;
	bool flag =0;
	for (int i= 1;i<=n;i++) cin>>a[i];
	int tmp = 0,j=0;
	for (int i = 1;i<=n;i++) if (a[i]==1) tmp++;
	for (int i=1;i<=n;i++) if ((tmp>0)&&(a[i]!=1)&&(prime(1+a[i]))){
		flag = 1;
		j=i;
		break;
	}
	if (flag){
		cout<<tmp+1<<endl;
		for (int i=1;i<=tmp;i++) cout<<1<<" ";
		cout<<a[j]<<endl;
	}
	else if (tmp>=2){
				cout<<tmp<<endl;
		for (int i=1;i<=tmp;i++) cout<<1<<" ";
		cout<<endl;
	}
	else{
	for (int i=1;i<=n;i++){
		if (flag) break;
		for (int j=1;j<i;j++){
			if (flag) break;
			if (prime(a[i]+a[j])){
				cout<<2<<endl<<a[i]<<" "<<a[j]<<endl;
				flag=1;
			}
		}
	}
	if (!flag) cout<<1<<endl<<a[1]<<endl;
}
	return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
using namespace std;
bool f[1000001];
bool prime(int x){
	return f[x];
}
int main(){
	memset(f, 1, sizeof(f));
	f[0]=0;f[1]=0;
	for (int i = 2; i <= 1000000; i++)
		for (int j = 2; i * j <= 1000000; j++)
			f[i*j]=0;
	int n, a[10001];
	cin >> n;
	bool flag =0;
	for (int i= 1;i<=n;i++) cin>>a[i];
	int tmp = 0,j=0;
	for (int i = 1;i<=n;i++) if (a[i]==1) tmp++;
	for (int i=1;i<=n;i++) if ((tmp>0)&&(a[i]!=1)&&(prime(1+a[i]))){
		flag = 1;
		j=i;
		break;
	}
	if (flag){
		cout<<tmp+1<<endl;
		for (int i=1;i<=tmp;i++) cout<<1<<" ";
		cout<<a[j]<<endl;
	}
	else if (tmp>=2){
				cout<<tmp<<endl;
		for (int i=1;i<=tmp;i++) cout<<1<<" ";
		cout<<endl;
	}
	else{
	for (int i=1;i<=n;i++){
		if (flag) break;
		for (int j=1;j<i;j++){
			if (flag) break;
			if (prime(a[i]+a[j])){
				cout<<2<<endl<<a[i]<<" "<<a[j]<<endl;
				flag=1;
			}
		}
	}
	if (!flag) cout<<1<<endl<<a[1]<<endl;
}
	return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
using namespace std;
bool prime(int x){
	int flag = 1;
	for (int i = 2; i <= sqrt(x); i++)
		if (x % i == 0){
			flag = 0;
			break;
		}
	return flag;
}
int main(){
	int n, a[10000];
	cin >> n;
	bool flag =0;
	for (int i= 1;i<=n;i++) cin>>a[i];
	int tmp = 0,j=0;
	for (int i = 1;i<=n;i++) if (a[i]==1) tmp++;
	for (int i=1;i<=n;i++) if ((tmp>0)&&(a[i]!=1)&&(prime(1+a[i]))){
		flag = 1;
		j=i;
		break;
	}
	if (flag){
		cout<<tmp+1<<endl;
		for (int i=1;i<=tmp;i++) cout<<1<<" ";
		cout<<a[j]<<endl;
	}
	else{
	for (int i=1;i<=n;i++){
		if (flag) break;
		for (int j=1;j<i;j++){
			if (flag) break;
			if (prime(a[i]+a[j])){
				cout<<2<<endl<<a[i]<<" "<<a[j]<<endl;
				flag=1;
			}
		}
	}
	if (!flag) cout<<1<<endl<<a[1]<<endl;
}
	return 0;
}


//2016-05-25 19:48:59.371000
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <memory.h>
#define NN 3000000

using namespace std;

int vst[NN];
int a[1010],ev[NN],od[NN];

void pre(){
	for(int i=2; i<NN; i++){
		if(vst[i]) continue;
		if(i>2000) continue;
		for(int j=i*i; j<NN; j+=i) vst[j]=1;
	}
}

int main (){

	pre();

	int N,i,j;
	int n=0,m=0;

	scanf("%d",&N);
	for(i=0; i<N; i++){
		scanf("%d",a+i);
		if(a[i]%2) od[n++]=a[i];
		else ev[m++]=a[i];
	}

	if(n==N || m==N){
		puts("1");
		printf("%d\n",a[0]);
		return 0;
	}

	for(i=0; i<m; i++){
		for(j=0; j<n; j++){
			if(vst[ev[i]+od[j]]==0) break;
		}
		if(j<n) break;
	}

	if(i==m) {
		puts("1");
		printf("%d\n",a[0]);
		return 0;
	}

	puts("2");
	printf("%d %d\n",ev[i],od[j]);

	return 0;
}


//2016-05-25 19:52:19.290000
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <queue>
#include <map>

using namespace std;

#define beyond(x, y) (x<0 || y<0 || x>=N || y>=M)
#define sq(x) ((x)*(x))
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3fLL
#define eps 1e-7

typedef long long INT;
typedef long double DO;
typedef pair<int, int> pii;

template<class T> inline void smin(T &a, T b) {if (a>b) a=b;}
template<class T> inline void smax(T &a, T b) {if (a<b) a=b;}

int dx[]={1, 0, -1, 0, 1, 1, -1, -1};
int dy[]={0, 1, 0, -1, -1, 1, 1, -1};
#define NN 1111111
int a[1111], od[NN], ev[NN], flag[NN], cnt[NN];

void pre() {
	flag[1]=1;
	int i, j;
	for (i=2; i<NN; i++) {
		if (flag[i]) continue;
		for (j=i; j<NN/i; j++) flag[i*j]=1;
	}
}

int main() {

	int T, N, i, j, M, k, no, ne, p, q;
	pre();
	scanf("%d", &N);
	for (i=0; i<N; i++) scanf("%d", a+i);
	sort(a, a+N);
	for (i=0; i<N; i++) cnt[a[i]]++;
	N=unique(a, a+N)-a;
	ne=no=0;
	for (i=0; i<N; i++) {
		if (a[i]%2==0) ev[ne++]=a[i];
		else od[no++]=a[i];
	}

	int res=0;
	for (i=0; i<ne; i++) {
		for (j=0; j<no; j++) {
			if (flag[ev[i]+od[j]]) continue;
			if (res<cnt[ev[i]]+cnt[od[j]]) res=cnt[ev[i]]+cnt[od[j]], p=ev[i], q=od[j];
		}
	}

	if (res) {
		printf("%d\n\n", res);
		for (i=0; i<cnt[p]; i++) {
			printf("%d ", p);
		}
		for (i=0; i<cnt[q]; i++) {
			if (i) printf(" ");
			printf("%d", q);
		}
	} else {
		for (i=0; i<no; i++) {
			if (flag[od[i]]) continue;
			break;
		}
		if (i<no) res=1, p=od[i];
		if (ev[0]==2) res=1, p=2;
		printf("%d\n\n", res);
		for (i=0; i<res; i++) {
			if (i) printf(" ");
			printf("%d", p);
		}
	}
	return 0;
}


//2016-05-25 19:59:48.577000
#include <algorithm>
#include <stdio.h>
#include <memory.h>
#include <string.h>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>

using namespace std;

typedef pair<int, int> pii;
typedef long long INT;

#define NN 2100000

int N;
int a[1100], cnt[NN];
int com[NN];
int mx, u, v;

int prepare() {
	for (int i=2; i<NN; i++) {
		if (com[i]) continue;
		for (int j=i*2; j<NN; j+=i)
			com[j]=1;
	}
}

int main() {
	prepare();

	scanf("%d", &N);
	for (int i=0; i<N; i++)
		scanf("%d", &a[i]);

	for (int i=0; i<N; i++) {
		cnt[a[i]]++;
		if (a[i]>1) cnt[a[i]]=1;
	}

	for (int i=0; i<N; i++) {
		if (mx<1 && !com[a[i]]) {
			mx=1; u=a[i]; v=-1;
		}
		if (a[i]==1 && cnt[a[i]]>mx) {
			mx=cnt[a[i]];
			u=a[i]; v=-1;
		}
		for (int j=i+1; j<N; j++) {
			if (a[i]==a[j]) continue;
			if (!com[a[i]+a[j]] && cnt[a[i]]+cnt[a[j]]>mx) {
				mx=cnt[a[i]]+cnt[a[j]];
				u=a[i]; v=a[j];
			}
		}
	}

	printf("%d\n", mx);
	if (mx==1) {
		printf("%d\n", u);
	} else {
		for (int i=0; i<cnt[u]; i++) {
			if (i) printf(" ");
			printf("%d", u);
		}
		if (v!=-1) {
			for (int i=0; i<cnt[v]; i++) printf(" %d", v);
		}
		puts("");
	}

	return 0;
}


//2016-05-25 19:53:13.378000
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <memory.h>
#define NN 3000000

using namespace std;

int vst[NN];
int a[1010],ev[NN],od[NN];

void pre(){
	for(int i=2; i<NN; i++){
		if(vst[i]) continue;
		if(i>2000) continue;
		for(int j=i*i; j<NN; j+=i) vst[j]=1;
	}
}

int main (){

	pre();

	int N,i,j;
	int n=0,m=0;
	int one=0,two=0;

	scanf("%d",&N);
	for(i=0; i<N; i++){
		scanf("%d",a+i);
		if(a[i]==1) one++;
		if(a[i]==2) two++;
		if(a[i]%2) od[n++]=a[i];
		else ev[m++]=a[i];
	}

	if(one>1 && two>0){
		puts("3");
		puts("1 1 2");
		return 0;
	}
	if(n==N || m==N){
		puts("1");
		printf("%d\n",a[0]);
		return 0;
	}

	for(i=0; i<m; i++){
		for(j=0; j<n; j++){
			if(vst[ev[i]+od[j]]==0) break;
		}
		if(j<n) break;
	}

	if(i==m) {
		puts("1");
		printf("%d\n",a[0]);
		return 0;
	}

	puts("2");
	printf("%d %d\n",ev[i],od[j]);

	return 0;
}


//2016-05-25 20:04:08.386000
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <map>

using namespace std;

#define beyond(x, y) (x<0 || y<0 || x>=N || y>=M)
#define sq(x) ((x)*(x))
#define x first
#define y second

typedef pair<int, int> pii;
typedef long long INT;
template <class T> inline void smin(T &a, T b) {if (a>b) a=b;}
template <class T> inline void smax(T &a, T b) {if (a<b) a=b;}
int dx[]={1, 0, -1, 0, 1, 1, -1, -1};
int dy[]={0, 1, 0, -1, -1, 1, 1, -1};
#define NN 2222222
int p[NN];
int qf, qb, q[1111111];
int a[1111], res1[1111], res[1111], b[1111];

int pre() {
	memset(p, 0, sizeof(p));
	int i, j;
	for (i=2; i<NN; i++) {
		if (p[i]) continue;
		if (i>NN/i) continue;
		for (j=i*i; j<NN; j+=i) p[j]=1;
	}
}

int main() {

	int n, i, j, mm, ok, cnt1, nn;
	pre();

	while (scanf("%d", &n)==1) {
		for (i=0; i<n; i++) scanf("%d", a+i);
		cnt1=nn=0;
		for (i=0; i<n; i++) {
			if (a[i]!=1) b[nn++]=a[i];
			else cnt1++;
		}

		if (nn==0) {
			printf("%d\n", cnt1);
			for (i=0; i<cnt1; i++) {
				if (i) printf(" ");
				printf("1");
			}
			puts("");
		} else {
			ok=1; res[0]=b[0];
			for (i=0; i<nn; i++) for (j=0; j<i; j++) {
				if (p[b[i]+b[j]]==0) {
					ok=2; res[0]=b[i]; res[1]=b[j];
					break;
				}
				if (ok==2) break;
			}

			if (cnt1) {
				mm=cnt1;
				for (i=0; i<nn; i++) {
					if (p[b[i]+1]) continue;
					if (p[b[i]+1]==0 && mm==cnt1) {
						for (j=0; j<cnt1; j++) res1[j]=1;
						res1[cnt1]=b[i]; mm=cnt1+1;
					}

					for (j=0; j<i; j++) {
						if (p[b[j]+1]) continue;
						if (p[b[i]+b[j]]==0) {
							for (j=0; j<cnt1; j++) res1[j]=1;
							res1[cnt1]=b[i]; res1[cnt1+1]=b[j];
							mm=cnt1+2;
							break;
						}
					}
					if (mm==cnt1+2) break;
				}
			} else mm=0;

			if (ok>mm) {
				printf("%d\n", ok);
				for (i=0; i<ok; i++) printf("%d ", res[i]);
				puts("");
			} else {
				printf("%d\n", mm);
				for (i=0; i<mm; i++) printf("%d ", res1[i]);
				puts("");
			}
		}
	}

	return 0;
}


//2016-05-25 20:24:11.916000
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <memory.h>
#define NN 3000000

using namespace std;

int vst[NN];
int a[1010],od[1010],ev[1010];

void pre(){
	for(int i=2; i<NN; i++){
		if(vst[i]) continue;
		if(i>2000) continue;
		for(int j=i*i; j<NN; j+=i) vst[j]=1;
	}
}

int main (){

	pre();

	int N,i,j;
	int n=0,m=0;
	int one=0;

	scanf("%d",&N);
	for(i=0; i<N; i++){
		scanf("%d",a+i);
		if(a[i]==1) one++;
		if(a[i]%2) od[n++]=a[i];
		else ev[m++]=a[i];
	}

	if(one>1){
		for(i=0; i<m; i++){
			if(vst[ev[i]+1]==0) break;
		}
		if(i<m){
			printf("%d\n",one+1);
			printf("%d",ev[i]);
			for(i=0; i<one; i++){
				printf(" 1");
			}
			puts("");
			return 0;
		}
		printf("%d\n",one);
		printf("1");
		for(i=1; i<one; i++) printf(" 1");
		puts("");
		return 0;
	}

	if(n==N || m==N){
		puts("1");
		printf("%d\n",a[0]);
		return 0;
	}

	for(i=0; i<m; i++){
		for(j=0; j<n; j++){
			if(!vst[ev[i]+od[j]]) break;
		}
		if(j<n) break;
	}

	if(i<m){
		puts("2");
		printf("%d %d\n",ev[i],od[j]);
		return 0;
	}

	puts("1");
	printf("%d\n",a[0]);

	return 0;
}


//2016-05-25 20:21:25.353000
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <queue>
#include <map>

using namespace std;

#define beyond(x, y) (x<0 || y<0 || x>=N || y>=M)
#define sq(x) ((x)*(x))
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3fLL
#define eps 1e-7

typedef long long INT;
typedef long double DO;
typedef pair<int, int> pii;

template<class T> inline void smin(T &a, T b) {if (a>b) a=b;}
template<class T> inline void smax(T &a, T b) {if (a<b) a=b;}

int dx[]={1, 0, -1, 0, 1, 1, -1, -1};
int dy[]={0, 1, 0, -1, -1, 1, 1, -1};
#define NN 3111111
int a[1111], od[NN], ev[NN], flag[NN], cnt[NN];

void pre() {
	flag[1]=1;
	int i, j;
	for (i=2; i<NN; i++) {
		if (flag[i]) continue;
		for (INT j=(INT)i*i; j<NN; j+=i) flag[j]=1;
	}
}

int main() {

	int T, N, i, j, M, k, no, ne, q;
	pre();
	scanf("%d", &N);
	for (i=0; i<N; i++) scanf("%d", a+i);
	sort(a, a+N);
	for (i=0; i<N; i++) cnt[a[i]]++;
	N=unique(a, a+N)-a;
	ne=no=0;
	for (i=0; i<N; i++) {
		if (a[i]%2==0) ev[ne++]=a[i];
		else od[no++]=a[i];
	}

	int res=0, c=0, cc[11], p[11];
	for (i=0; i<ne; i++) {
		for (j=0; j<no; j++) {
			if (flag[ev[i]+od[j]]) continue;
			if (od[j]==1) {
				if (res<cnt[1]+1) c=0, res=cnt[1]+1, p[c]=ev[i], cc[c++]=1, p[c]=1, cc[c++]=cnt[1];
			} else {
				if (res<2) c=0, res=2, p[c]=ev[i], cc[c++]=1, p[c]=od[j], cc[c++]=1;
			}
		}
	}
	if (res<cnt[1]) c=0, res=cnt[1], p[c]=1, cc[c++]=cnt[1];
	if (res<1) c=0, res=1, p[c]=a[0], cc[c++]=1;
	printf("%d\n\n", res);
	for (i=0; i<c; i++) {
		for (j=0; j<cc[i]; j++) {
			if (i+j) printf(" ");
			printf("%d", p[i]);
		}
	}
	puts("");

	return 0;
}


//2016-05-25 19:48:03.641000
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <map>

using namespace std;

#define beyond(x, y) (x<0 || y<0 || x>=N || y>=M)
#define sq(x) ((x)*(x))
#define x first
#define y second

typedef pair<int, int> pii;
typedef long long INT;
template <class T> inline void smin(T &a, T b) {if (a>b) a=b;}
template <class T> inline void smax(T &a, T b) {if (a<b) a=b;}
int dx[]={1, 0, -1, 0, 1, 1, -1, -1};
int dy[]={0, 1, 0, -1, -1, 1, 1, -1};
#define NN 2222222
int p[NN];
int qf, qb, q[1111111];
int a[1111], res1[1111], res[1111], b[1111];

int pre() {
	memset(p, 0, sizeof(p));
	int i, j;
	for (i=2; i<NN; i++) {
		if (p[i]) continue;
		if (i>NN/i) continue;
		for (j=i*i; j<NN; j+=i) p[j]=1;
	}
}

int main() {

	int n, i, j, mm, ok, cnt1, nn;
	pre();

	while (scanf("%d", &n)==1) {
		for (i=0; i<n; i++) scanf("%d", a+i);
		cnt1=nn=0;
		for (i=0; i<n; i++) {
			if (a[i]!=1) b[nn++]=a[i];
			else cnt1++;
		}

		if (nn==0) {
			printf("%d\n", cnt1);
			for (i=0; i<cnt1; i++) {
				if (i) printf(" ");
				printf("1");
			}
			puts("");
		} else {

			ok=1; res[0]=b[0];
			for (i=0; i<nn; i++) for (j=0; j<i; j++) {
				if (p[b[i]+b[j]]==0) {
					ok=2; res[0]=b[i]; res[1]=b[j];
					break;
				}
				if (ok==2) break;
			}

			if (cnt1) {
				mm=cnt1;
				for (i=0; i<nn; i++) {
					if (p[b[i]+1]==0 && mm==cnt1) {
						for (j=0; j<cnt1; j++) res1[j]=1;
						res1[cnt1]=b[i]; mm=cnt1+1;
					}

					for (j=0; j<i; j++) {
						if (p[b[j]+1]==0 && p[b[i]+b[j]]==0) {
							for (j=0; j<cnt1; j++) res1[j]=1;
							res1[cnt1]=b[i]; res1[cnt1+1]=b[j];
							mm=cnt1+2;
							break;
						}
					}
					if (mm==cnt1+2) break;
				}
			} else mm=0;

			if (ok>mm) {
				printf("%d\n", ok);
				for (i=0; i<ok; i++) printf("%d ", res[i]);
				puts("");
			} else {
				printf("%d\n", mm);
				for (i=0; i<mm; i++) printf("%d ", res1[i]);
				puts("");
			}
		}
	}

	return 0;
}


//2016-05-25 20:36:30.873000
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <map>

using namespace std;

#define beyond(x, y) (x<0 || y<0 || x>=N || y>=M)
#define sq(x) ((x)*(x))
#define x first
#define y second

typedef pair<int, int> pii;
typedef long long INT;
template <class T> inline void smin(T &a, T b) {if (a>b) a=b;}
template <class T> inline void smax(T &a, T b) {if (a<b) a=b;}
int dx[]={1, 0, -1, 0, 1, 1, -1, -1};
int dy[]={0, 1, 0, -1, -1, 1, 1, -1};
#define NN 2222222
int p[NN];
int qf, qb, q[1111111];
int a[1111], res1[1111], res[1111], b[1111];

int pre() {
	memset(p, 0, sizeof(p));
	int i, j;
	for (i=2; i<NN; i++) {
		if (p[i]) continue;
		if (i>NN/i) continue;
		for (j=i*i; j<NN; j+=i) p[j]=1;
	}
}

int main() {

	int n, i, j, mm, ok, cnt1, nn;
	pre();

	while (scanf("%d", &n)==1) {
		for (i=0; i<n; i++) scanf("%d", a+i);
		cnt1=nn=0;
		for (i=0; i<n; i++) {
			if (a[i]!=1) b[nn++]=a[i];
			else cnt1++;
		}

		if (nn==0) {
			printf("%d\n", cnt1);
			for (i=0; i<cnt1; i++) {
				if (i) printf(" ");
				printf("1");
			}
			puts("");
		} else {
			ok=1; res[0]=b[0];
			for (i=0; i<nn; i++) for (j=0; j<i; j++) {
				if (p[b[i]+b[j]]==0) {
					ok=2; res[0]=b[i]; res[1]=b[j];
					break;
				}
				if (ok==2) break;
			}

			if (cnt1) {
				mm=cnt1;
				for (i=0; i<cnt1; i++) res1[i]=1;
				for (i=0; i<nn; i++) {
					if (p[b[i]+1]) continue;
					if (mm==cnt1) {
						for (j=0; j<cnt1; j++) res1[j]=1;
						res1[cnt1]=b[i]; mm=cnt1+1;
					}

					for (j=0; j<i; j++) {
						if (p[b[j]+1]) continue;
						if (p[b[i]+b[j]]==0) {
							for (j=0; j<cnt1; j++) res1[j]=1;
							res1[cnt1]=b[i]; res1[cnt1+1]=b[j];
							mm=cnt1+2;
							break;
						}
					}
					if (mm==cnt1+2) break;
				}
			} else mm=0;

			if (ok>mm) {
				printf("%d\n", ok);
				for (i=0; i<ok; i++) printf("%d ", res[i]);
				puts("");
			} else {
				printf("%d\n", mm);
				for (i=0; i<mm; i++) printf("%d ", res1[i]);
				puts("");
			}
		}
	}

	return 0;
}


//2016-05-25 20:22:04.580000
#include <algorithm>
#include <stdio.h>
#include <memory.h>
#include <string.h>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>

using namespace std;
typedef long long INT;
#define NN 2000010
int mk[NN],p[NN],a[NN],vst[NN],cnt=0,b[NN];
int main(){
//	freopen("d.in","r",stdin);
	int n,i,j,m=0;
	memset(mk,0,sizeof(mk));
	for(i=2;i<NN;i++){
		if(mk[i]) continue;
		p[cnt++]=i;
		if(i>2000) continue;
		for(j=i*i;j<NN;j+=i) mk[j]=1;
	}
	memset(vst,0,sizeof(vst));
	for(i=0;i<cnt;i++) vst[p[i]]=1;
	scanf("%d",&n);
	int jina=-1,jinb=-1;
	for(i=0;i<n;i++) scanf("%d",a+i);
	sort(a,a+n);
	for(i=0;i<n;i++){
		if(a[i]==1) continue;
			for(j=i+1;j<n;j++){
				if(vst[a[i]+a[j]]){
					jina=a[i];jinb=a[j];
			}
		}
	}
	if(a[0]>1){
		if(jina==-1 && jinb==-1) printf("1\n%d\n",a[0]);
		else printf("2\n%d %d\n",jina,jinb);
	}
	else{
		cnt=0;
		for(i=0;i<n;i++)
			if(a[i]==1) cnt++;
		for(i=cnt;i<n;i++)
			if(vst[a[i]+1]) b[m++]=a[i];
		if(cnt==1){
			if(jina==-1 && jinb==-1){
				if(m>0){
					printf("2\n1 %d\n",b[0]);
				}
				else puts("1\n1");
			}
			else{
				if(cnt>2){
					if(m==0){
						printf("%d\n",cnt);
						for(i=0;i<cnt;i++) printf("1 ");
						}
					else{
						printf("%d\n",cnt+1);
						for(i=0;i<cnt;i++) printf("1 ");
						printf("%d\n",b[0]);
					}
				}
				else printf("2\n%d %d\n",jina,jinb);
			}
			return 0;
		}
		jina=jinb=-1;
		for(i=0;i<m;i++){
			for(j=i+1;j<m;j++){
				if(vst[b[i]+b[j]]){
					jina=b[i];
					jinb=b[j];
				}
			}
		}
		if(jina>0){
			printf("%d\n",cnt+2);
			for(i=0;i<n;i++) printf("1 ");
			printf("%d %d\n",jina,jinb);
		}
		else{
			if(m) {
				printf("%d\n",cnt+1);
				for(i=0;i<cnt;i++) printf("1 ");
				 printf("%d\n",b[0]);
			}
			else {
				printf("%d\n",cnt);
				for(i=0;i<cnt;i++) printf("1 ");
			}
		}
	}
}


//2016-05-25 19:44:27.087000
#include <algorithm>
#include <stdio.h>
#include <memory.h>
#include <string.h>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>

using namespace std;

typedef pair<int, int> pii;
typedef long long INT;

#define NN 1100000

int N;
int a[1100], cnt[NN];
int com[NN];
int mx, u, v;

int prepare() {
	for (int i=2; i<NN; i++) {
		if (com[i]) continue;
		for (int j=i*2; j<NN; j+=i)
			com[j]=1;
	}
}

int main() {
	prepare();

	scanf("%d", &N);
	for (int i=0; i<N; i++)
		scanf("%d", &a[i]);

	for (int i=0; i<N; i++) {
		cnt[a[i]]++;
		if (a[i]>1) cnt[a[i]]=1;
	}

	for (int i=0; i<N; i++) {
		if (mx<1 && !com[a[i]]) {
			mx=1; u=a[i]; v=-1;
		}
		if (!com[a[i]*2] && cnt[a[i]]>mx) {
			mx=cnt[a[i]];
			u=a[i]; v=-1;
		}
		for (int j=i+1; j<N; j++) {
			if (a[i]==a[j]) continue;
			if (!com[a[i]+a[j]] && cnt[a[i]]+cnt[a[j]]>mx) {
				mx=cnt[a[i]]+cnt[a[j]];
				u=a[i]; v=a[j];
			}
		}
	}

	printf("%d\n", mx);
	if (mx==1) {
		printf("%d\n", u);
	} else {
		for (int i=0; i<cnt[u]; i++) printf("%d ", u);
		if (v!=-1) {
			for (int i=0; i<cnt[v]; i++) printf("%d ", v);
		}
		puts("");
	}

	return 0;
}


//2016-05-25 19:58:13.612000
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <memory.h>
#define NN 3000000

using namespace std;

int vst[NN];
int a[1010],ev[NN],od[NN];

void pre(){
	for(int i=2; i<NN; i++){
		if(vst[i]) continue;
		if(i>2000) continue;
		for(int j=i*i; j<NN; j+=i) vst[j]=1;
	}
}

int main (){

	pre();

	int N,i,j;
	int n=0,m=0;
	int one=0,two=0;

	scanf("%d",&N);
	for(i=0; i<N; i++){
		scanf("%d",a+i);
		if(a[i]==1) one++;
		if(a[i]==2) two++;
		if(a[i]%2) od[n++]=a[i];
		else ev[m++]=a[i];
	}

	if(one>1 && two>0){
		printf("%d\n",one+1);
		printf("2");
		for(i=0; i<one; i++){
			printf(" 1");
		}
		puts("");
		return 0;
	}
	if(n==N || m==N){
		puts("1");
		printf("%d\n",a[0]);
		return 0;
	}

	for(i=0; i<m; i++){
		for(j=0; j<n; j++){
			if(vst[ev[i]+od[j]]==0) break;
		}
		if(j<n) break;
	}

	if(i==m) {
		puts("1");
		printf("%d\n",a[0]);
		return 0;
	}

	puts("2");
	printf("%d %d\n",ev[i],od[j]);

	return 0;
}


//2016-05-25 19:57:03.786000
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <map>

using namespace std;

#define beyond(x, y) (x<0 || y<0 || x>=N || y>=M)
#define sq(x) ((x)*(x))
#define x first
#define y second

typedef pair<int, int> pii;
typedef long long INT;
template <class T> inline void smin(T &a, T b) {if (a>b) a=b;}
template <class T> inline void smax(T &a, T b) {if (a<b) a=b;}
int dx[]={1, 0, -1, 0, 1, 1, -1, -1};
int dy[]={0, 1, 0, -1, -1, 1, 1, -1};
#define NN 2222222
int p[NN];
int qf, qb, q[1111111];
int a[1111], res1[1111], res[1111], b[1111];

int pre() {
	memset(p, 0, sizeof(p));
	int i, j;
	for (i=2; i<NN; i++) {
		if (p[i]) continue;
		if (i>NN/i) continue;
		for (j=i*i; j<NN; j+=i) p[j]=1;
	}
}

int main() {

	int n, i, j, mm, ok, cnt1, nn;
	pre();

	while (scanf("%d", &n)==1) {
		for (i=0; i<n; i++) scanf("%d", a+i);
		cnt1=nn=0;
		for (i=0; i<n; i++) {
			if (a[i]!=1) b[nn++]=a[i];
			else cnt1++;
		}

		if (nn==0) {
			printf("%d\n", cnt1);
			for (i=0; i<cnt1; i++) {
				if (i) printf(" ");
				printf("1");
			}
			puts("");
		} else {

			ok=1; res[0]=b[0];
			for (i=0; i<nn; i++) for (j=0; j<i; j++) {
				if (p[b[i]+b[j]]==0) {
					ok=2; res[0]=b[i]; res[1]=b[j];
					break;
				}
				if (ok==2) break;
			}

			if (cnt1) {
				mm=cnt1;
				for (i=0; i<nn; i++) {
					if (p[b[i]+1]==0 && mm==cnt1) {
						for (j=0; j<cnt1; j++) res1[j]=1;
						res1[cnt1]=b[i]; mm=cnt1+1;
					}

					for (j=0; j<i; j++) {
						if (p[b[i]+1]==0 && p[b[j]+1]==0 && p[b[i]+b[j]]==0) {
							for (j=0; j<cnt1; j++) res1[j]=1;
							res1[cnt1]=b[i]; res1[cnt1+1]=b[j];
							mm=cnt1+2;
							break;
						}
					}
					if (mm==cnt1+2) break;
				}
			} else mm=0;

			if (ok>mm) {
				printf("%d\n", ok);
				for (i=0; i<ok; i++) printf("%d ", res[i]);
				puts("");
			} else {
				printf("%d\n", mm);
				for (i=0; i<mm; i++) printf("%d ", res1[i]);
				puts("");
			}
		}
	}

	return 0;
}


//2016-05-25 19:56:28.029000
#include <algorithm>
#include <stdio.h>
#include <memory.h>
#include <string.h>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>

using namespace std;
typedef long long INT;
#define NN 2000010
int mk[NN],p[NN],a[NN],vst[NN],cnt=0,b[NN];
int main(){
//	freopen("d.in","r",stdin);
	int n,i,j,m=0;
	memset(mk,0,sizeof(mk));
	for(i=2;i<NN;i++){
		if(mk[i]) continue;
		p[cnt++]=i;
		if(i>2000) continue;
		for(j=i*i;j<NN;j+=i) mk[j]=1;
	}
	memset(vst,0,sizeof(vst));
	for(i=0;i<cnt;i++) vst[p[i]]=1;
	scanf("%d",&n);
	int jina=-1,jinb=-1;
	for(i=0;i<n;i++) scanf("%d",a+i);
	sort(a,a+n);
	for(i=0;i<n;i++){
		if(a[i]==1) continue;
			for(j=i+1;j<n;j++){
				if(vst[a[i]+a[j]]){
					jina=a[i];jinb=a[j];
			}
		}
	}
	if(a[0]>1){
		if(jina==-1 && jinb==-1) printf("1\n%d\n",a[0]);
		else printf("2\n%d %d\n",jina,jinb);
	}
	else{
		cnt=0;
		for(i=0;i<n;i++)
			if(a[i]==1) cnt++;
		for(i=cnt;i<n;i++)
			if(vst[a[i]+1]) b[m++]=a[i];
		if(cnt==1){
			if(jina==-1 && jinb==-1){
				if(m>0){
					printf("2\n1 %d\n",b[0]);
				}
				else puts("1\n1");
			}
			else{
				if(cnt>2){
					if(m==0){
						printf("%d\n",cnt);
						for(i=0;i<cnt;i++) printf("1 ");
						}
					else{
						printf("%d\n",cnt+1);
						for(i=0;i<cnt;i++) printf("1 ");
						printf("%d\n",b[0]);
					}
				}
				else printf("2\n%d %d\n",jina,jinb);
			}
			return 0;
		}
		jina=jinb=-1;
		for(i=0;i<m;i++){
			for(j=i+1;j<m;j++){
				if(vst[b[i]+b[j]]){
					jina=b[i];
					jinb=b[j];
				}
			}
		}
		if(jina>0){
			printf("%d\n",cnt+2);
			for(i=0;i<n;i++) printf("1 ");
			printf("%d %d\n",jina,jinb);
		}
		else{
			printf("%d\n",cnt+m);
			for(i=0;i<cnt;i++) printf("1 ");
			for(i=0;i<m;i++) printf("%d ",b[i]);
		}
	}
}


//2016-05-25 20:08:45.705000
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <queue>
#include <map>

using namespace std;

#define beyond(x, y) (x<0 || y<0 || x>=N || y>=M)
#define sq(x) ((x)*(x))
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3fLL
#define eps 1e-7

typedef long long INT;
typedef long double DO;
typedef pair<int, int> pii;

template<class T> inline void smin(T &a, T b) {if (a>b) a=b;}
template<class T> inline void smax(T &a, T b) {if (a<b) a=b;}

int dx[]={1, 0, -1, 0, 1, 1, -1, -1};
int dy[]={0, 1, 0, -1, -1, 1, 1, -1};
#define NN 2111111
int a[1111], od[NN], ev[NN], flag[NN], cnt[NN];

void pre() {
	flag[1]=1;
	int i, j;
	for (i=2; i<NN; i++) {
		if (flag[i]) continue;
		for (j=i; j<NN/i; j++) flag[i*j]=1;
	}
}

int main() {

	int T, N, i, j, M, k, no, ne, q;
	pre();
	scanf("%d", &N);
	for (i=0; i<N; i++) scanf("%d", a+i);
	sort(a, a+N);
	for (i=0; i<N; i++) cnt[a[i]]++;
	N=unique(a, a+N)-a;
	ne=no=0;
	for (i=0; i<N; i++) {
		if (a[i]%2==0) ev[ne++]=a[i];
		else od[no++]=a[i];
	}

	int res=0, c=0, cc[11], p[11];
	for (i=0; i<ne; i++) {
		if (!flag[ev[i]]) {
			if (res<1) c=0, res=1, p[c]=ev[i], cc[c++]=1;
		}
		for (j=0; j<no; j++) {
			if (!flag[od[j]] && res<1) c=0, res=1, p[c]=od[j], cc[c++]=1;
			if (flag[ev[i]+od[j]]) continue;
			if (od[j]==1) {
				if (res<cnt[1]+1) c=0, res=cnt[1]+1, p[c]=ev[i], cc[c++]=1, p[c]=1, cc[c++]=cnt[1];
			} else {
				if (res<2) c=0, res=2, p[c]=ev[i], cc[c++]=1, p[c]=od[j], cc[c++]=1;
			}
		}
	}
	printf("%d\n\n", res);
	for (i=0; i<c; i++) {
		for (j=0; j<cc[i]; j++) {
			if (i+j) printf(" ");
			printf("%d", p[i]);
		}
	}

	return 0;
}


//2016-05-25 20:03:33.196000
#include <algorithm>
#include <stdio.h>
#include <memory.h>
#include <string.h>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>

using namespace std;

typedef pair<int, int> pii;
typedef long long INT;

#define NN 2100000

int N;
int a[1100], cnt[NN];
int com[NN];
int mx, u, v;

int prepare() {
	for (int i=2; i<NN; i++) {
		if (com[i]) continue;
		for (int j=i*2; j<NN; j+=i)
			com[j]=1;
	}
}

int main() {
	prepare();

	scanf("%d", &N);
	for (int i=0; i<N; i++)
		scanf("%d", &a[i]);

	for (int i=0; i<N; i++) {
		cnt[a[i]]++;
		if (a[i]>1) cnt[a[i]]=1;
	}

	for (int i=0; i<N; i++) {
		if (mx<1) {
			mx=1; u=a[i]; v=-1;
		}
		if (a[i]==1 && cnt[a[i]]>mx) {
			mx=cnt[a[i]];
			u=a[i]; v=-1;
		}
		for (int j=i+1; j<N; j++) {
			if (a[i]==a[j]) continue;
			if (!com[a[i]+a[j]] && cnt[a[i]]+cnt[a[j]]>mx) {
				mx=cnt[a[i]]+cnt[a[j]];
				u=a[i]; v=a[j];
			}
		}
	}

	printf("%d\n", mx);
	if (mx==1) {
		printf("%d\n", u);
	} else {
		for (int i=0; i<cnt[u]; i++) {
			if (i) printf(" ");
			printf("%d", u);
		}
		if (v!=-1) {
			for (int i=0; i<cnt[v]; i++) printf(" %d", v);
		}
		puts("");
	}

	return 0;
}


//2016-05-25 20:15:15.766000
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <queue>
#include <map>

using namespace std;

#define beyond(x, y) (x<0 || y<0 || x>=N || y>=M)
#define sq(x) ((x)*(x))
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3fLL
#define eps 1e-7

typedef long long INT;
typedef long double DO;
typedef pair<int, int> pii;

template<class T> inline void smin(T &a, T b) {if (a>b) a=b;}
template<class T> inline void smax(T &a, T b) {if (a<b) a=b;}

int dx[]={1, 0, -1, 0, 1, 1, -1, -1};
int dy[]={0, 1, 0, -1, -1, 1, 1, -1};
#define NN 3111111
int a[1111], od[NN], ev[NN], flag[NN], cnt[NN];

void pre() {
	flag[1]=1;
	int i, j;
	for (i=2; i<NN; i++) {
		if (flag[i]) continue;
		for (j=i; j<NN/i; j++) flag[i*j]=1;
	}
}

int main() {
	int T, N, i, j, M, k, no, ne, q;
	pre();
	scanf("%d", &N);
	for (i=0; i<N; i++) scanf("%d", a+i);
	sort(a, a+N);
	for (i=0; i<N; i++) cnt[a[i]]++;
	N=unique(a, a+N)-a;
	ne=no=0;
	for (i=0; i<N; i++) {
		if (a[i]%2==0) ev[ne++]=a[i];
		else od[no++]=a[i];
	}

	int res=0, c=0, cc[11], p[11];
	for (i=0; i<ne; i++) {
		for (j=0; j<no; j++) {
			if (flag[ev[i]+od[j]]) continue;
			if (od[j]==1) {
				if (res<cnt[1]+1) c=0, res=cnt[1]+1, p[c]=ev[i], cc[c++]=1, p[c]=1, cc[c++]=cnt[1];
			} else {
				if (res<2) c=0, res=2, p[c]=ev[i], cc[c++]=1, p[c]=od[j], cc[c++]=1;
			}
		}
	}
	if (res<1) c=0, res=1, p[c]=a[0], cc[c++]=1;
	printf("%d\n\n", res);
	for (i=0; i<c; i++) {
		for (j=0; j<cc[i]; j++) {
			if (i+j) printf(" ");
			printf("%d", p[i]);
		}
	}

	return 0;
}


//2016-05-25 20:12:29.615000
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <memory.h>
#define NN 3000000

using namespace std;

int vst[NN];
int a[1010];
int tot[1010];

void pre(){
	for(int i=2; i<NN; i++){
		if(vst[i]) continue;
		if(i>2000) continue;
		for(int j=i*i; j<NN; j+=i) vst[j]=1;
	}
}

int main (){

	pre();

	int N,i,j;

	scanf("%d",&N);
	for(i=0; i<N; i++){
		scanf("%d",a+i);
	}

	tot[0]=1;

	int mx=1,id=0;

	for(i=1; i<N; i++){
		for(j=i-1; j>i-1-tot[i-1]; j--){
			if(vst[a[i]+a[j]]) break;
		}
		tot[i]=i-j;
		if(tot[i]>mx){
			mx=tot[i];
			id=i;
		}
	}

	printf("%d\n",mx);
	for(i=0; i<mx; i++){
		if(i==0) printf("%d",a[id]);
		else printf(" %d",a[id-i]);
	}
	puts("");
	return 0;
}


//2016-05-25 19:43:36.792000
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <queue>
#include <string.h>
#include <vector>
#include <cmath>
#include <bitset>
#include <map>

using namespace std;

#define NN 2000100
#define rep(i, a, b) for (int i = (a); i < (b); i ++)
#define clr(a, b) memset(a, b, sizeof(a))
#define eps 1e-10
#define inf 1000000000

typedef long long INT;
typedef pair<int, int> pii;
typedef pair<pii, int> pi3;

int vst[NN], p[NN], np;
int a[NN], b[NN], c[NN];

void prepare() {
	clr(vst, 0);
	for (int i = 2; i < NN; i ++) {
		if (vst[i]) continue ;
		if (i > 10000) continue ;
		for (int j = i * i; j < NN; j += i) vst[j] = 1;
	}
	return ;
}

int main() {

	int N, bm, cm;
	prepare();
	scanf("%d", &N);
	rep(i, 0, N) scanf("%d", a + i);
	bm = 0; cm = 0;
	rep(i, 0, N) {
		if (a[i] == 1) {
			b[bm ++] = 1;
		}
	}

	bool ok = false ;

	rep(i, 0, N) {
		if (a[i] == 1) continue ;
		rep(j, 0, N) {
			if (a[j] == 1) continue ;
			if (vst[a[i] + a[j]] == 0) {
				cm = 0;
				c[cm ++] = a[i];
				c[cm ++] = a[j];
				if (bm && vst[a[i] + 1] == 0 && vst[a[j] + 1] == 0) {
					ok = true ;
					b[bm ++] = a[i];
					b[bm ++] = a[j];
					break ;
				}
			}
		}
		if (ok) break ;
	}
	if (!ok && bm) {
		rep(i, 0, N) {
			if (a[i] == 1) continue ;
			if (vst[a[i] + 1] == 0) {
				b[bm ++ ] = a[i];
				break ;
			}
		}
	}

	if (bm == 0 && cm == 0) {
		puts("1");
		printf("%d\n", a[0]);
	} else {
		if (bm > cm) {
			printf("%d\n", bm);
			rep(i, 0, bm)
				if (i == bm - 1) printf("%d\n", b[i]);
				else printf("%d ", b[i]);
		} else {
			printf("%d\n", cm);
			rep(i, 0, cm)
				if (i == cm - 1) printf("%d\n", c[i]);
				else printf("%d ", c[i]);
		}
	}

	return 0;
}


#include<iostream>
#include<cstring>
using namespace std;
const int maxn=1e6+5;
int a[1005];
bool p[maxn];
void pre()
{
    for(int i=2;i*i<maxn;i++)
        for(int j=i+i;j<maxn;j+=i)
            p[j]=1;
}
int main()
{
    pre();
    int n,i,j;
    scanf("%d",&n);
    int cnt=0;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]==1)cnt++;
    }
    if(cnt>1)
    {
        for(i=0;i<n;i++)
            if(!p[a[i]+1]&&a[i]!=1)
                break;
        if(i<n)cnt++;
        printf("%d\n",cnt);
        if(i<n)printf("%d ",a[i]);
        for(i=0;i<cnt-1;i++)
            printf("1 ");
    }
    else
    {
        for(i=0;i<n;i++)
            {
                for(j=i+1;j<n;j++)
                    if(!p[a[i]+a[j]])break;
                if(j<n)break;
            }
        if(i<n)
            puts("2"),printf("%d %d\n",a[i],a[j]);
        else
        {
            for(i=0;i<n;i++)
                if(!p[a[i]])break;
            if(i==n)puts("0");
            else printf("1\n%d\n",a[i]);
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=1e6+5;
int a[1005];
bool p[maxn];
void pre()
{
    for(int i=2;i*i<maxn;i++)
        for(int j=i+i;j<maxn;j+=i)
            p[j]=1;
}
int main()
{
    pre();
    int n,i,j;
    scanf("%d",&n);
    int cnt=0;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]==1)cnt++;
    }
    if(cnt>1)
    {
        for(i=0;i<n;i++)
            if(!p[a[i]+1]&&a[i]!=1)
                break;
        if(i<n)cnt++;
        printf("%d\n",cnt);
        if(i<n)printf("%d ",a[i]);
        for(j=0;j<(i<n?cnt-1:cnt);j++)
            printf("1 ");
    }
    else
    {
        for(i=0;i<n;i++)
            {
                for(j=i+1;j<n;j++)
                    if(!p[a[i]+a[j]])break;
                if(j<n)break;
            }
        if(i<n)
            puts("2"),printf("%d %d\n",a[i],a[j]);
        else
        {
            for(i=0;i<n;i++)
                if(!p[a[i]])break;
            if(i==n)printf("1\n%d\n",a[0]);
            else printf("1\n%d\n",a[i]);
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=1e6+5;
int a[1005];
bool p[maxn];
void pre()
{
    for(int i=2;i*i<maxn;i++)
        for(int j=i+i;j<maxn;j+=i)
            p[j]=1;
}
int main()
{
    pre();
    int n,i,j;
    scanf("%d",&n);
    int cnt=0;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]==1)cnt++;
    }
    if(cnt>1)
    {
        for(i=0;i<n;i++)
            if(!p[a[i]+1]&&a[i]!=1)
                break;
        if(i<n)cnt++;
        printf("%d\n",cnt);
        if(i<n)printf("%d ",a[i]);
        for(j=0;j<(i<n?cnt-1:cnt);j++)
            printf("1 ");
    }
    else
    {
        for(i=0;i<n;i++)
            {
                for(j=i+1;j<n;j++)
                    if(!p[a[i]+a[j]])break;
                if(j<n)break;
            }
        if(i<n)
            puts("2"),printf("%d %d\n",a[i],a[j]);
        else
        {
            for(i=0;i<n;i++)
                if(!p[a[i]])break;
            if(i==n)puts("0");
            else printf("1\n%d\n",a[i]);
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=1e6+5;
int a[1005];
bool p[maxn];
void pre()
{
    for(int i=2;i*i<maxn;i++)
        for(int j=i+i;j<maxn;j+=i)
            p[j]=1;
}
int main()
{
    pre();
    int n,i,j;
    scanf("%d",&n);
    int cnt=0;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]==1)cnt++;
    }
    if(cnt>1)
    {
        for(i=0;i<n;i++)
            if(!p[a[i]+1]&&a[i]!=1)
                break;
        if(i<n)cnt++;
        printf("%d\n",cnt);
        if(i<n)printf("%d ",a[i]);
        for(i=0;i<cnt-1;i++)
            printf("1 ");
    }
    else
    {
        for(i=0;i<n;i++)
            {
                for(j=i+1;j<n;j++)
                    if(!p[a[i]+a[j]])break;
                if(j<n)break;
            }
        if(i<n)
            puts("2"),printf("%d %d\n",a[i],a[j]);
        else
        {
            for(i=0;i<n;i++)
                if(!p[a[i]])break;
            if(i==n)puts("0");
            else printf("1\n%d\n",a[i]);
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=2e6+5;
int a[1005];
bool p[maxn];
void pre()
{
    for(int i=2;i*i<maxn;i++)
        for(int j=i+i;j<maxn;j+=i)
            p[j]=1;
}
int main()
{
    pre();
    int n,i,j;
    scanf("%d",&n);
    int cnt=0;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]==1)cnt++;
    }
    if(cnt>1)
    {
        for(i=0;i<n;i++)
            if(!p[a[i]+1]&&a[i]!=1)
                break;
        if(i<n)cnt++;
        printf("%d\n",cnt);
        if(i<n)printf("%d ",a[i]);
        for(j=0;j<(i<n?cnt-1:cnt);j++)
            printf("1 ");
    }
    else
    {
        for(i=0;i<n;i++)
            {
                for(j=i+1;j<n;j++)
                    if(!p[a[i]+a[j]])break;
                if(j<n)break;
            }
        if(i<n)
            puts("2"),printf("%d %d\n",a[i],a[j]);
        else
        {
            for(i=0;i<n;i++)
                if(!p[a[i]])break;
            if(i==n)printf("1\n%d\n",a[0]);
            else printf("1\n%d\n",a[i]);
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=1e6+5;
int a[1005];
bool p[maxn];
void pre()
{
    for(int i=2;i*i<maxn;i++)
        for(int j=i+i;j<maxn;j+=i)
            p[j]=1;
}
int main()
{
    pre();
    int n,i,j;
    scanf("%d",&n);
    int cnt=0;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]==1)cnt++;
    }
    if(cnt>1)
    {
        for(i=0;i<n;i++)
            if(!p[a[i]+1]&&a[i]!=1)
                break;
        if(i<n)cnt++;
        printf("%d\n",cnt);
        if(i<n)printf("%d ",a[i]);
        for(j=0;i<n?cnt-1:cnt;j++)
            printf("1 ");
    }
    else
    {
        for(i=0;i<n;i++)
            {
                for(j=i+1;j<n;j++)
                    if(!p[a[i]+a[j]])break;
                if(j<n)break;
            }
        if(i<n)
            puts("2"),printf("%d %d\n",a[i],a[j]);
        else
        {
            for(i=0;i<n;i++)
                if(!p[a[i]])break;
            if(i==n)puts("0");
            else printf("1\n%d\n",a[i]);
        }
    }
    return 0;
}


#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<set>
using namespace std;
multiset<int>sp;
int a[1005],b[1005],vis[2000005];
int main(){
	int n,i,num=1,j;
	for(i=2;i<=2000000;i++){
		if(vis[i])continue;
		for(j=2;j<=sqrt(i);j++){
			if(i%j==0){
				vis[i]=1;
				break;
			}
		}
		if(vis[i]){
			for(j=i*2;j<=2000000;j+=i)vis[j]=1;
		}
	}
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sp.insert(a[i]);
	}
	multiset<int>::iterator it,it1;
	if(sp.count(1)>1){
		for(i=1;i<=sp.count(1);i++)b[i]=1;
		num=sp.count(1);
		for(it=sp.begin();it!=sp.end();it++){
			if(*it>1&&!vis[*it+1]){
				b[++num]=*it;
				break;
			}
		}
	}
	else if(sp.count(1)==1){
		b[1]=1;
		num=1;
		it=sp.begin();
		it++;
		for(;it!=sp.end();it++){
			if(!vis[*it+1]){
				b[++num]=*it;
				break;
			}
		}
	}
	else{
		int flag=0;
		num=0;
		for(it=sp.begin();it!=sp.end();it++){
			it1=sp.begin();
			it1++;
			for(;it1!=sp.end();it1++){
				if(!vis[*it+*it1]){
					b[1]=*it;
					b[2]=*it1;
					num=2;
					flag=1;
					break;
				}
			}
			if(flag)break;
		}
		if(flag==0){
			it=sp.begin();
			num=1;
			b[1]=*it;
		}
	}
	cout<<num<<endl;
	for(i=1;i<=num;i++){
		cout<<b[i];
		if(i!=num)cout<<" ";
		else cout<<endl;
	}
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<set>
using namespace std;
multiset<int>sp;
int a[1005],b[1005],vis[2000005];
int main(){
	int n,i,num=1,j;
	for(i=2;i<=2000000;i++){
		if(vis[i])continue;
		for(j=2;j<=sqrt(i);j++){
			if(i%j==0){
				vis[i]=1;
				break;
			}
		}
		if(vis[i]){
			for(j=i*2;j<=2000000;j+=i)vis[j]=1;
		}
	}
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sp.insert(a[i]);
	}
	multiset<int>::iterator it,it1;
	if(sp.count(1)>1){
		for(i=1;i<=sp.count(1);i++)b[i]=1;
		num=sp.count(1);
		for(it=sp.begin();it!=sp.end();it++){
			if(*it>1&&!vis[*it+1]){
				b[++num]=*it;
				break;
			}
		}
	}
	else if(sp.count(1)==1){
		b[1]=1;
		num=1;
		for(it=sp.begin();it!=sp.end();it++){
			if(!vis[*it+1]){
				b[++num]=*it;
				break;
			}
		}
	}
	else{
		int flag=0;
		num=0;
		for(it=sp.begin();it!=sp.end();it++){
			it1=sp.begin();
			it1++;
			for(;it1!=sp.end();it1++){
				if(!vis[*it+*it1]){
					b[1]=*it;
					b[2]=*it1;
					num=2;
					flag=1;
					break;
				}
			}
			if(flag)break;
		}
		if(flag==0){
			it=sp.begin();
			num=1;
			b[1]=*it;
		}
	}
	cout<<num<<endl;
	for(i=1;i<=num;i++){
		cout<<b[i];
		if(i!=num)cout<<" ";
		else cout<<endl;
	}
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<set>
using namespace std;
multiset<int>sp;
int a[1005],b[1005],vis[2000005];
int main(){
	int n,i,num=1,j;
	for(i=2;i<=2000000;i++){
		if(vis[i])continue;
		for(j=2;j<=sqrt(i);j++){
			if(i%j==0){
				vis[i]=1;
				break;
			}
		}
		if(vis[i]){
			for(j=i*2;j<=2000000;j+=i)vis[j]=1;
		}
	}
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sp.insert(a[i]);
	}
	multiset<int>::iterator it,it1;
	if(sp.count(1)>1){
		for(i=1;i<=sp.count(1);i++)b[i]=1;
		num=sp.count(1);
		for(it=sp.begin();it!=sp.end();it++){
			if(*it>1&&!vis[*it+1]){
				b[++num]=*it;
				break;
			}
		}
	}
	else{
		int flag=0;
		num=0;
		for(it=sp.begin();it!=sp.end();it++){
			it1=sp.begin();
			it1++;
			for(;it1!=sp.end();it1++){
				if(!vis[*it+*it1]){
					b[1]=*it;
					b[2]=*it1;
					num=2;
					flag=1;
					break;
				}
			}
			if(flag)break;
		}
		if(flag==0){
			it=sp.begin();
			num=1;
			b[1]=*it;
		}
	}
	cout<<num<<endl;
	for(i=1;i<=num;i++){
		cout<<b[i];
		if(i!=num)cout<<" ";
		else cout<<endl;
	}
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<set>
using namespace std;
multiset<int>sp;
int a[1005],b[1005],vis[200005];
int main(){
	int n,i,num=1,j;
	for(i=2;i<=200000;i++){
		if(vis[i])continue;
		for(j=2;j<=sqrt(i);j++){
			if(i%j==0){
				vis[i]=1;
				break;
			}
		}
		if(vis[i]){
			for(j=i*2;j<=200000;j+=i)vis[j]=1;
		}
	}
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sp.insert(a[i]);
	}
	multiset<int>::iterator it,it1;
	if(sp.count(1)>1){
		for(i=1;i<=sp.count(1);i++)b[i]=1;
		num=sp.count(1);
		for(it=sp.begin();it!=sp.end();it++){
			if(*it>1&&!vis[*it+1]){
				b[++num]=*it;
				break;
			}
		}
	}
	else if(sp.count(1)==1){
		b[1]=1;
		num=1;
		for(it=sp.begin();it!=sp.end();it++){
			if(!vis[*it+1]){
				b[++num]=*it;
				break;
			}
		}
	}
	else{
		int flag=0;
		num=0;
		for(it=sp.begin();it!=sp.end();it++){
			it1=sp.begin();
			it1++;
			for(;it1!=sp.end();it1++){
				if(!vis[*it+*it1]){
					b[1]=*it;
					b[2]=*it1;
					num=2;
					flag=1;
					break;
				}
			}
			if(flag)break;
		}
		if(flag==0){
			it=sp.begin();
			num=1;
			b[1]=*it;
		}
	}
	cout<<num<<endl;
	for(i=1;i<=num;i++){
		cout<<b[i];
		if(i!=num)cout<<" ";
		else cout<<endl;
	}
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<set>
using namespace std;
multiset<int>sp;
int a[1005],b[1005],vis[200005];
int main(){
	int n,i,num=1,j;
	for(i=2;i<=200000;i++){
		if(vis[i])continue;
		for(j=2;j<=sqrt(i);j++){
			if(i%j==0){
				vis[i]=1;
				break;
			}
		}
		if(vis[i]){
			for(j=i*2;j<=200000;j+=i)vis[j]=1;
		}
	}
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sp.insert(a[i]);
	}
	multiset<int>::iterator it,it1;
	if(sp.count(1)>1){
		for(i=1;i<=sp.count(1);i++)b[i]=1;
		num=sp.count(1);
		for(it=sp.begin();it!=sp.end();it++){
			if(*it>1&&!vis[*it+1]){
				b[++num]=*it;
				break;
			}
		}
	}
	else if(sp.count(1)==1){
		b[1]=1;
		num=1;
		for(it=sp.begin();it!=sp.end();it++){
			if(!vis[*it+1]){
				b[++num]=*it;
				break;
			}
		}
	}
	else{
		int flag=0;
		num=0;
		for(it=sp.begin();it!=sp.end();it++){
			it1=sp.begin();
			it1++;
			for(;it1!=sp.end();it1++){
				if(!vis[*it+*it1]){
					b[1]=*it;
					b[2]=*it1;
					num=2;
					flag=1;
					break;
				}
			}
			if(flag)break;
		}
	}
	cout<<num<<endl;
	for(i=1;i<=num;i++){
		cout<<b[i];
		if(i!=num)cout<<" ";
		else cout<<endl;
	}
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<set>
using namespace std;
multiset<int>sp;
int a[1005],b[1005],vis[200005];
int main(){
	int n,i,num=1,j;
	for(i=2;i<=200000;i++){
		if(vis[i])continue;
		for(j=2;j<=sqrt(i);j++){
			if(i%j==0){
				vis[i]=1;
				break;
			}
		}
		if(vis[i]){
			for(j=i*2;j<=200000;j+=i)vis[j]=1;
		}
	}
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sp.insert(a[i]);
	}
	multiset<ll>::iterator it,it1;
	if(sp.count(1)>1){
		for(i=1;i<=sp.count(1);i++)b[i]=1;
		num=sp.count(1);
		for(it=sp.begin();it!=sp.end();it++){
			if(*it>1&&!vis[*it+1]){
				b[++num]=*it;
				break;
			}
		}
	}
	else if(sp.count(1)==1){
		b[1]=1;
		num=1;
		for(it=sp.begin();it!=sp.end();it++){
			if(!vis[*it+1]){
				b[++num]=*it;
				break;
			}
		}
	}
	else{
		int flag=0;
		num=0;
		for(it=sp.begin();it!=sp.end();it++){
			it1=sp.begin();
			it1++;
			for(;it1!=sp.end();it1++){
				if(!vis[*it+*it1]){
					b[1]=*it;
					b[2]=*it1;
					num=2;
					flag=1;
					break;
				}
			}
			if(flag)break;
		}
	}
	cout<<num<<endl;
	for(i=1;i<=num;i++){
		cout<<b[i];
		if(i!=num)cout<<" ";
		else cout<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>

#define mp make_pair
#define vi vector<int>
#define xx first
#define yy second
#define all(a) a.begin(), a.end()
#define vsort(v) sort(all(v))
#define UNIQUE(a)  sort(all(a)); a.erase(unique(all(a)), a.end())
#define clr(a,k) memset(a,k,sizeof a)
#define bclr(b) memset(b,false,sizeof b)
#define fr(i, a) for(i = 0; i < a; i++)
#define frr(i,a) for(i = a - 1; i >= 0, i--)
#define LL long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define vll vector<long long>
///***** bit *****///
#define check_bit(a, b) (a&(1<<b))
#define set_bit(a, b) (a|(1<<b))
#define total_bit(a) __builtin_popcount(a)

#define WRITE freopen("C:\\Users\\back_bencher\\Desktop\\output.txt","w",stdout)
#define use_cin  ios_base::sync_with_stdio(0); cin.tie(0);
#define READ  freopen("C:\\Users\\back_bencher\\Desktop\\input.txt","r",stdin)

///***** Input / Output *****///
#define s1(a) scanf("%d", &a)
#define s2(a, b) scanf("%d %d", &a, &b)
#define s3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define s4(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
#define p1(a) printf("%d", a)
#define p2(a, b) printf("%d %d", a, b)
#define p3(a, b, c) printf("%d %d %d", a, b, c)
#define eps 1e-9
#define deb cout<<"I am here"<<endl
#define MOD 1000000007
#define MAX (lim+7)
#define INF 100000000
#define PI acos(-1.0)

using namespace std;

///******* Template ********///

template <class T> inline T bigmod(T p,T e,T M)
{
    if(e==0)return 1;
    if(e%2==0)
    {
        T t=bigmod(p,e/2,M);
        return (t*t)%M;
    }
    return (bigmod(p,e-1,M)*p)%M;
}
template <class T> inline T gcd(T a,T b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
template <class T> inline T modinverse(T a,T M)
{
    return bigmod(a,M-2,M);
}

/**
return (a * b) % m;
where a, b, m <= 10^18
**/
template <class T> inline T multimod(T a, T b, T m)
{
    T ans = 0ll;
    a%=m, b%=m;
    while(b)
    {
        if(b&1ll) ans = m - ans > a?(ans + a): (ans + a - m);
        b >>= 1ll;
        a = (m - a)>a?a+a:a+a-m;
    }
    return (T)ans;
}

///****** fast scan ends here ***********///

//int dr[] = {-1, 0, 1, 0};
//int dc[] = {0, 1, 0, -1}; /// 4 sides
//int dr[] = {-1, -1, 0, 1, 1, 1, 0, -1}; dc[] = {0, 1, 1, 1, 0, -1, -1, -1}; /// 8 sides

#define LEN(a) strlen(a)

#define MX 1000000000000000000ll
#define lim 1000      /// 10^5
#define MX 100000
///***** Template ends here *****///
///********************* Code starts here ****************************

bool is[MX];
int prime[MX];
int k;
void sieve()
{
    int i,j;

    int sq=(sqrt(MX));
    for(i = 2; i < MX; i++)
    {
        if(!is[i])
        {
            prime[k++] = i;
            for(j = i+i; j < MX; j+=i)
                is[j] = 1;
        }
    }
}

bool check(int a)
{
    int sq = sqrt(a);
    if(a < MX) return is[a]==0;
    for(int i = 0; i < k && prime[i] <= sq; i++)
    {
        if(a%prime[i] == 0) return false;
    }
    return true;
}

int ans[MAX];

int arr[MAX];

int main()
{
    int  j,  num, i;
    int t, cases = 1;
    int sum = 0;
    int n, q;
    sieve();
    s1(n);
    for(i = 0; i < n; i++)
        s1(arr[i]);

    int cnt = 5000;
    int mx = 0;
    while(cnt--)
    {
        random_shuffle(arr, arr+n);
        for(i = 0; i < n; i++)
        {
            for(j = 0; j < i; j++)
            {
                if(!check(arr[i]+arr[j])) break;
            }
            if(j<i) break;
        }
        if(mx < i)
        {
            mx = i;
            for(j = 0; j < i; j++)
                ans[j] = arr[j];
        }
    }
    printf("%d\n", mx);
    sort(ans, ans + mx);
    for(i = 0; i < mx; i++)
        printf("%d ", ans[i]);

    return 0;
}
/*

2
5 1
1 2 3 4 5
2 5 10
1 3 2
1 4 1

*/


#include<bits/stdc++.h>

#define mp make_pair
#define vi vector<int>
#define xx first
#define yy second
#define all(a) a.begin(), a.end()
#define vsort(v) sort(all(v))
#define UNIQUE(a)  sort(all(a)); a.erase(unique(all(a)), a.end())
#define clr(a,k) memset(a,k,sizeof a)
#define bclr(b) memset(b,false,sizeof b)
#define fr(i, a) for(i = 0; i < a; i++)
#define frr(i,a) for(i = a - 1; i >= 0, i--)
#define LL long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define vll vector<long long>
///***** bit *****///
#define check_bit(a, b) (a&(1<<b))
#define set_bit(a, b) (a|(1<<b))
#define total_bit(a) __builtin_popcount(a)

#define WRITE freopen("C:\\Users\\back_bencher\\Desktop\\output.txt","w",stdout)
#define use_cin  ios_base::sync_with_stdio(0); cin.tie(0);
#define READ  freopen("C:\\Users\\back_bencher\\Desktop\\input.txt","r",stdin)

///***** Input / Output *****///
#define s1(a) scanf("%d", &a)
#define s2(a, b) scanf("%d %d", &a, &b)
#define s3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define s4(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
#define p1(a) printf("%d", a)
#define p2(a, b) printf("%d %d", a, b)
#define p3(a, b, c) printf("%d %d %d", a, b, c)
#define eps 1e-9
#define deb cout<<"I am here"<<endl
#define MOD 1000000007
#define MAX (lim+7)
#define INF 100000000
#define PI acos(-1.0)

using namespace std;

///******* Template ********///

template <class T> inline T bigmod(T p,T e,T M)
{
    if(e==0)return 1;
    if(e%2==0)
    {
        T t=bigmod(p,e/2,M);
        return (t*t)%M;
    }
    return (bigmod(p,e-1,M)*p)%M;
}
template <class T> inline T gcd(T a,T b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
template <class T> inline T modinverse(T a,T M)
{
    return bigmod(a,M-2,M);
}

/**
return (a * b) % m;
where a, b, m <= 10^18
**/
template <class T> inline T multimod(T a, T b, T m)
{
    T ans = 0ll;
    a%=m, b%=m;
    while(b)
    {
        if(b&1ll) ans = m - ans > a?(ans + a): (ans + a - m);
        b >>= 1ll;
        a = (m - a)>a?a+a:a+a-m;
    }
    return (T)ans;
}

///****** fast scan ends here ***********///

//int dr[] = {-1, 0, 1, 0};
//int dc[] = {0, 1, 0, -1}; /// 4 sides
//int dr[] = {-1, -1, 0, 1, 1, 1, 0, -1}; dc[] = {0, 1, 1, 1, 0, -1, -1, -1}; /// 8 sides

#define LEN(a) strlen(a)

#define MX 1000000000000000000ll
#define lim 1000      /// 10^5
#define MX 1000000
///***** Template ends here *****///
///********************* Code starts here ****************************

bool is[MX];
int prime[MX];
int k;
void sieve()
{
    int i,j;

    int sq=(sqrt(MX));
    for(i = 2; i < MX; i++)
    {
        if(!is[i])
        {
            prime[k++] = i;
            for(j = i+i; j < MX; j+=i)
                is[j] = 1;
        }
    }
}

bool check(int a)
{
    int sq = sqrt(a);
    if(a < MX) return is[a]==0;
    for(int i = 0; i < k && prime[i] <= sq; i++)
    {
        if(a%prime[i] == 0) return false;
    }
    return true;
}

int ans[MAX];

int arr[MAX];

int main()
{
    int  j,  num, i;
    int t, cases = 1;
    int sum = 0;
    int n, q;
    sieve();
    s1(n);
    for(i = 0; i < n; i++)
        s1(arr[i]);

    int cnt = 50000;
    int mx = 0;
    while(cnt--)
    {
        random_shuffle(arr, arr+n);
        for(i = 0; i < n; i++)
        {
            for(j = 0; j < i; j++)
            {
                if(!check(arr[i]+arr[j])) break;
            }
            if(j<i) break;
        }
        if(mx < i)
        {
            mx = i;
            for(j = 0; j < i; j++)
                ans[j] = arr[j];
        }
    }
    printf("%d\n", mx);
    sort(ans, ans + mx);
    for(i = 0; i < mx; i++)
        printf("%d ", ans[i]);

    return 0;
}
/*

2
5 1
1 2 3 4 5
2 5 10
1 3 2
1 4 1

*/


#include<bits/stdc++.h>

#define mp make_pair
#define vi vector<int>
#define xx first
#define yy second
#define all(a) a.begin(), a.end()
#define vsort(v) sort(all(v))
#define UNIQUE(a)  sort(all(a)); a.erase(unique(all(a)), a.end())
#define clr(a,k) memset(a,k,sizeof a)
#define bclr(b) memset(b,false,sizeof b)
#define fr(i, a) for(i = 0; i < a; i++)
#define frr(i,a) for(i = a - 1; i >= 0, i--)
#define LL long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define vll vector<long long>
///***** bit *****///
#define check_bit(a, b) (a&(1<<b))
#define set_bit(a, b) (a|(1<<b))
#define total_bit(a) __builtin_popcount(a)

#define WRITE freopen("C:\\Users\\back_bencher\\Desktop\\output.txt","w",stdout)
#define use_cin  ios_base::sync_with_stdio(0); cin.tie(0);
#define READ  freopen("C:\\Users\\back_bencher\\Desktop\\input.txt","r",stdin)

///***** Input / Output *****///
#define s1(a) scanf("%d", &a)
#define s2(a, b) scanf("%d %d", &a, &b)
#define s3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define s4(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
#define p1(a) printf("%d", a)
#define p2(a, b) printf("%d %d", a, b)
#define p3(a, b, c) printf("%d %d %d", a, b, c)
#define eps 1e-9
#define deb cout<<"I am here"<<endl
#define MOD 1000000007
#define MAX (lim+7)
#define INF 100000000
#define PI acos(-1.0)

using namespace std;

///******* Template ********///

template <class T> inline T bigmod(T p,T e,T M)
{
    if(e==0)return 1;
    if(e%2==0)
    {
        T t=bigmod(p,e/2,M);
        return (t*t)%M;
    }
    return (bigmod(p,e-1,M)*p)%M;
}
template <class T> inline T gcd(T a,T b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
template <class T> inline T modinverse(T a,T M)
{
    return bigmod(a,M-2,M);
}

/**
return (a * b) % m;
where a, b, m <= 10^18
**/
template <class T> inline T multimod(T a, T b, T m)
{
    T ans = 0ll;
    a%=m, b%=m;
    while(b)
    {
        if(b&1ll) ans = m - ans > a?(ans + a): (ans + a - m);
        b >>= 1ll;
        a = (m - a)>a?a+a:a+a-m;
    }
    return (T)ans;
}

///****** fast scan ends here ***********///

//int dr[] = {-1, 0, 1, 0};
//int dc[] = {0, 1, 0, -1}; /// 4 sides
//int dr[] = {-1, -1, 0, 1, 1, 1, 0, -1}; dc[] = {0, 1, 1, 1, 0, -1, -1, -1}; /// 8 sides

#define LEN(a) strlen(a)

#define MX 1000000000000000000ll
#define lim 1000      /// 10^5
#define MX 100000
///***** Template ends here *****///
///********************* Code starts here ****************************

bool is[MX];
int prime[MX];
int k;
void sieve()
{
    int i,j;

    int sq=(sqrt(MX));
    for(i = 2; i < MX; i++)
    {
        if(!is[i])
        {
            prime[k++] = i;
            for(j = i+i; j < MX; j+=i)
                is[j] = 1;
        }
    }
}

bool check(int a)
{
    int sq = sqrt(a);
    if(a < MX) return is[a]==0;
    for(int i = 0; i < k && prime[i] <= sq; i++)
    {
        if(a%prime[i] == 0) return false;
    }
    return true;
}

int ans[MAX];

int arr[MAX];

int main()
{
    int  j,  num, i;
    int t, cases = 1;
    int sum = 0;
    int n, q;
    sieve();
    s1(n);
    for(i = 0; i < n; i++)
        s1(arr[i]);

    int cnt = 50000;
    int mx = 0;
    while(cnt--)
    {
        random_shuffle(arr, arr+n);
        for(i = 0; i < n; i++)
        {
            for(j = 0; j < i; j++)
            {
                if(!check(arr[i]+arr[j])) break;
            }
            if(j<i) break;
        }
        if(mx < i)
        {
            mx = i;
            for(j = 0; j < i; j++)
                ans[j] = arr[j];
        }
    }
    printf("%d\n", mx);
    sort(ans, ans + mx);
    for(i = 0; i < mx; i++)
        printf("%d ", ans[i]);

    return 0;
}
/*

2
5 1
1 2 3 4 5
2 5 10
1 3 2
1 4 1

*/


#include<bits/stdc++.h>

#define mp make_pair
#define vi vector<int>
#define xx first
#define yy second
#define all(a) a.begin(), a.end()
#define vsort(v) sort(all(v))
#define UNIQUE(a)  sort(all(a)); a.erase(unique(all(a)), a.end())
#define clr(a,k) memset(a,k,sizeof a)
#define bclr(b) memset(b,false,sizeof b)
#define fr(i, a) for(i = 0; i < a; i++)
#define frr(i,a) for(i = a - 1; i >= 0, i--)
#define LL long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define vll vector<long long>
///***** bit *****///
#define check_bit(a, b) (a&(1<<b))
#define set_bit(a, b) (a|(1<<b))
#define total_bit(a) __builtin_popcount(a)

#define WRITE freopen("C:\\Users\\back_bencher\\Desktop\\output.txt","w",stdout)
#define use_cin  ios_base::sync_with_stdio(0); cin.tie(0);
#define READ  freopen("C:\\Users\\back_bencher\\Desktop\\input.txt","r",stdin)

///***** Input / Output *****///
#define s1(a) scanf("%d", &a)
#define s2(a, b) scanf("%d %d", &a, &b)
#define s3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define s4(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
#define p1(a) printf("%d", a)
#define p2(a, b) printf("%d %d", a, b)
#define p3(a, b, c) printf("%d %d %d", a, b, c)
#define eps 1e-9
#define deb cout<<"I am here"<<endl
#define MOD 1000000007
#define MAX (lim+7)
#define INF 100000000
#define PI acos(-1.0)

using namespace std;

///******* Template ********///

template <class T> inline T bigmod(T p,T e,T M)
{
    if(e==0)return 1;
    if(e%2==0)
    {
        T t=bigmod(p,e/2,M);
        return (t*t)%M;
    }
    return (bigmod(p,e-1,M)*p)%M;
}
template <class T> inline T gcd(T a,T b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
template <class T> inline T modinverse(T a,T M)
{
    return bigmod(a,M-2,M);
}

/**
return (a * b) % m;
where a, b, m <= 10^18
**/
template <class T> inline T multimod(T a, T b, T m)
{
    T ans = 0ll;
    a%=m, b%=m;
    while(b)
    {
        if(b&1ll) ans = m - ans > a?(ans + a): (ans + a - m);
        b >>= 1ll;
        a = (m - a)>a?a+a:a+a-m;
    }
    return (T)ans;
}

///****** fast scan ends here ***********///

//int dr[] = {-1, 0, 1, 0};
//int dc[] = {0, 1, 0, -1}; /// 4 sides
//int dr[] = {-1, -1, 0, 1, 1, 1, 0, -1}; dc[] = {0, 1, 1, 1, 0, -1, -1, -1}; /// 8 sides

#define LEN(a) strlen(a)

#define MX 1000000000000000000ll
#define lim 2000000      /// 10^5

///***** Template ends here *****///
///********************* Code starts here ****************************

bool is[MAX];

void sieve()
{
    int sq = sqrt(MAX);
    is[1] = 1;
    int i, j;
    for(i = 4; i < MAX; i+=2) is[i] = 1;
    for(i = 3; i <= sq; i += 2)
    {
        if(!is[i])
        {
            for(j = i + i; j < MAX; j += i)
                is[j] = 1;
        }
    }

}

int arr[MAX];

int main()
{
    sieve();
    int i, j, k;
    int n, num, m, q;
    cin>>n;
    int cnt = 0;
    for(i = 0; i < n; i++)
    {
        cin>>arr[i];
        if(arr[i] == 1)
            cnt++;
    }
    if(cnt >= 2)
    {
        bool ck = 0;
        for(i = 0; i < n; i++)
        {
            if(arr[i] == 1) continue;
            if(is[ arr[i] + 1 ] == 0)
            {
                cout<<cnt+1<<endl;
                cout<<arr[i]<<" ";
                break;
            }
        }
        if(!ck)
            cout<<cnt<<endl;
        for(i = 0; i < cnt; i++)
            cout<<1<<" ";
            return 0;
    }
    else
    {
        for(i = 0; i < n; i++)
        {
            for(j = i + 1; j < n; j++)
            {
                if(! is[ arr[i]+arr[j] ])
                {
                    cout<<2<<endl;
                    cout<<arr[i]<<" "<<arr[j]<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<1<<endl;
    cout<<arr[0]<<endl;

    return 0;
}
/*

*/