We designed silicon nanowire array cavities with high optical confinement (Γ) in the central nanowire and a high quality factor (Q) through an inverse design method that maximizes Γ×Q. Moreover, we fabricated an inversely designed cavity with inline input and output waveguides, which is a new configuration for such cavities. The experimental Q exceeded 50,000, which was consistent with a simulation. The cavity exhibited the thermal nonlinearity effect and optical bistability, which indicate that our cavity strongly confines the light in the nanowires.