import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int [] A = new int [N]; int sum =0; for(int i=0; i0){ move+=t; } }else if(i<=z-1){ int t=A[i]-(z-i); if(t>0){ move+=t; } }else{ move+=A[i]; } } System.out.println(move); } }