#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define REP(i,n) for(long (i)=0;(i)<(n);(i)++) #define FOR(i,a,b) for(long (i)=(a);(i)<(b);(i)++) #define RREP(i,a) for(long (i)=(a)-1;(i)>=0;(i)--) #define FORR(i,a,b) for(long (i)=(a)-1;(i)>=(b);(i)--) #define MOD 1000000007 #define PI acos(-1.0) #define DEBUG(C) cout< #define VL vector #define VD vector #define PII pair #define PLL pair #define ALL(a) (a).begin(),(a).end() #define SORT(a) sort((a).begin(),(a).end()) #define RSORT(a) sort((a).begin(),(a).end(),greater()) #define MP(a,b) make_pair(a,b) #define FORE(a,b) for(auto &&a:b) #define INF 1e9 typedef long long LL; typedef unsigned long long ULL; using namespace std; bool isPrime(int a){ if(a<2) return false; for(int i=2;i*i<=a;i++){ if(a%i==0) return false; } return true; } int M,N; vector C; vector dp; int ans=0; int main(){ cin>>M>>N; C=vector(N); REP(i,N) cin>>C[i]; dp=vector(M+1,-INF); dp[M]=0; REP(i,N){ RREP(j,M-C[i]+1){ dp[j]=max(dp[j],dp[j+C[i]]+1); } } int ans=0; RREP(i,M+1){ //DEBUG(ans) if(isPrime(i)&&dp[i]>0) ans+=dp[i]; } SORT(dp); ans+=dp.back(); cout<