#include int main(){ int n,i; long x,y,d[15],g,dmax=0,ans=0; scanf("%d",&n); for(i=0;iy)?x:y; if(g>dmax*2){ ans+=(g-dmax-1)/dmax; g-=dmax*ans; } for(i=0;i