function F = lmaxcdf3(x,l,w,gbar,Etaext,Rext)
s_l = l/w*((Etaext(2:end-1)-Etaext(1:end-2))./(Rext(2:end-1)-Rext(1:end-2)));
s_u = l/w*((Etaext(3:end)-Etaext(2:end-1))./(Rext(3:end)-Rext(2:end-1)));
fg = l*Etaext(2:end-1)./max(w*Rext(2:end-1)-x,0);
fg(isnan()f)
F = sum(max(expcdf(min(fg,s_u),gbar)-expcdf(s_l,gbar),0));
end