#include<iostream>
#include<vector>
#include<cmath>
#include<set>
const int sq=sqrt(10000000);
using namespace std;
bool sieve[4000];
int prime[446];
void build()
{
int gap=2;
for(int i=5;i<=sq;i+=gap,gap=6-gap)
sieve[i]=true;
sieve[2]=true;
sieve[3]=true;
prime[0]=2;
prime[1]=3;
gap=2;
for(int i=5;i<=sqrt(sq);i+=gap,gap=6-gap)
{
if(sieve[i])
for(int j=i*i;j<=sq;j+=i)
sieve[j]=false;
}
gap=2;
int now=2;
for(int i=5;i<=sq;i+=gap,gap=6-gap)
if(sieve[i]) prime[now]=i,now++;
}
bool isprime(int n)
{
if(n<=sq) return sieve[n];
else
for(int i=0;(prime[i])*(prime[i])<=n&&i<=445;i++)
if(!(n%prime[i])) return 0;
return 1;
}
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(false);
build();
int i;
while(cin>>i)
{
vector<int> num;
num.push_back(i);
while(cin.get()!='\n')
{
cin>>i;
num.push_back(i);
}
long long ans=0;
long long tmp=0;
for(int i=0;i<num.size();i++)
{
if(!(isprime(num[i])))tmp=0;
else
{
if(i==0||num[i]<=num[i-1]||tmp==0) tmp=num[i];
else tmp+=num[i];
if(tmp>ans) ans=tmp;
}
}
cout<<ans<<endl;
}
return 0;
}