public static long solution(int n, int[] nums) {         long sum=0;         if(n<=2){             for(int num:nums){                 sum+=num;             }             return sum;         }         int res=0;         // 每次选择差值最大的进行踏前斩 Math.max(nums[i]+nums[i+1]+nums[i+2]-6)         while(res!=n-2){             res=0;             int index=-1;             long max=0;             for(int i=0;i<=n-3;i++){                 if(nums[i]>=1&&nums[i+1]>=2&&nums[i+2]>=3){                     int diff=nums[i]+nums[i+1]+nums[i+2]-6;                     if(diff>=max){                         index=i;                         max=diff;                     }                 }else{                     res++;                 }             }             if(index!=-1){                 sum+=5;                 nums[index]-=1;                 nums[index+1]-=2;                 nums[index+2]-=3;             }         }         for(int num:nums) sum+=Math.max(0,num); //普通攻击                  return sum;     }