Cooperative optical wavefront engineering with atomic arrays