仔细读题目,e(k)+e(k)-H(k+1)=e(k+1)
e(k)=(ek+1)+H(k+1))/2,注意这是临界条件,要用浮点数,完了向上取整。

import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        double[] ints = new double[n];
        for(int i = 0; i < n; i++){
            ints[i] = (double) scanner.nextInt();
        }
        double e = 0;
        int index = n - 1;
        while (index >= 0) {
            e = (e + ints[index]) / 2;
            index--;
        }
        //        System.out.println(e);
        System.out.println((int) Math.ceil(e));
    }
}