Energy levels of 6Be and 7Be observed in (p, n) reactions