  We introduce higher order variants of the Yang-Mills functional that involve
$(n-2)$th order derivatives of the curvature. We prove coercivity and
smoothness of critical points in Uhlenbeck gauge in dimensions
$\mathrm{dim}M\le 2n$. These results are then used to establish the existence
of smooth minimizers on a given principal bundle $P\to M$ for subcritical
dimensions $\mathrm{dim}M<2n$. In the case of critical dimension
$\mathrm{dim}M=2n$ we construct a minimizer on a bundle which might differ from
the prescribed one, but has the same Chern classes $c_1,\ldots,c_{n-1}$. A key
result is a removable singularity theorem for bundles carrying a
$W^{n-1,2}$-connection. This generalizes a recent result by Petrache and
Rivi\`ere.
