import java.util.*; import java.lang.Math; 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 ans=Integer.MAX_VALUE; int sum=0; for(int i=0;isum)continue; for(int j=0;jp[j]){ int m=Math.min(b[j]-p[j],s-y); b[j]-=m; s-=m; k+=m; } } } int u=0; for(int j=0;j