All-sky search for long-duration gravitational-wave transients in the second Advanced LIGO observing run