import java.util.*; import java.math.*; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 while (in.hasNextInt()) { // 注意 while 处理多个 case int n = in.nextInt(); int[] arr = new int[n]; for(int i=0;i<n;i++){ arr[i] = in.nextInt(); } //保存所有的最大间隔 List<Integer> ans = new ArrayList<>(); for(int i=1;i<n;i++){ //获取删除当前元素后的数组 List<Integer> currList = removeList(arr,i); //记录此时数组的最大间隔 int maxDiff = 0; for(int j=1;j<currList.size();j++){ int diff = currList.get(j)-currList.get(j-1); maxDiff=Math.max(maxDiff,diff); } ans.add(maxDiff); } Collections.sort(ans); System.out.println(ans.get(0)); } } public static List<Integer> removeList(int[] arr,int index){ List<Integer> res = new ArrayList<>(); for(int i=0;i<arr.length;i++){ if(i!=index) res.add(arr[i]); } return res; } }