import java.util.*;
public class Solution { /** * * @param n int整型 * @param a int整型一维数组 * @return int整型 */ public static boolean sushu(int n){ boolean flag=true; for(int i=2;i<n;i++) { if(n%i==0){ flag=false; break; } else{ flag=true; } } return flag; } public int work (int n, int[] a) { // write code here int count=1; for(int i=0;i<n-1;i++){ if(sushu(a[i+1]-a[i])){ count++; } else { if((a[i+1]-a[i])%2==0){ count+=2; } else{ if(sushu(a[i+1]-a[i]-2)){ count+=2; } else{ count+=3; } } } } return count; } }