Permanent-magnet trap for ultracold neutron storage