Topology bounds energy of knots and links