#include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int Need = 5000000; vector allp; vector prime(Need+1,true); prime.at(0) = false; prime.at(1) = false; for(int i=2; i<=Need; i++){ if(!prime.at(i)) continue; allp.push_back(i); for(long long k=((long long)i)*i; k<=Need; k+=i) prime.at(k) = false; } int n = allp.size(); vector use(n); for(int i=0; i> next(n,vector(10,n)); for(int i=n-1; i>=0; i--){ for(int k=0; k<10; k++){ if(use.at(i)&(1<> N; int A = 0; while(N--){ int a; cin >> a; A += 1<= two) continue; if(i == 0) answer = max(answer,allp.at(two)-1-1); else answer = max(answer,allp.at(two)-1-(allp.at(i-1)+1)); } cout << answer << endl; }