program main implicit none integer*8::C(26) integer*8::h,e,l,o,w,r,d,ml,mo read *,C h = C(8) e = C(5) l = C(12) o = C(15) w = C(23) r = C(18) d = C(4) if(h.lt.1 .or. e.lt.1 .or. l.lt.3 .or. & o.lt.2 .or. w.lt.1 .or. r.lt.1 .or. & d.lt.1) then print '(i0)',0 else ml = get_maxl(l) mo = get_maxo(o) print '(i0)',h*e*ml*mo*w*r*d end if contains function get_maxl(l) result(m) integer*8::i,m,l m = 1 do i=2,l-1 m = MAX(m, (l-i)*i*(i-1)/2) end do end function get_maxl function get_maxo(o) result(m) integer*8::i,m,o m = 1 do i=1,o-1 m = MAX(m, (o-i)*i) end do end function get_maxo end program main