We consider certain subsets of the space of n×n matrices of the form K=∪i=1mSO(n)Ai, and we prove that for p>1,q≥1 and for connected Ω′⊂⊂Ω⊂Rn, there exists positive constant a<1 depending on n,p,q,Ω,Ω′ such that for \veps=∥dist(Du,K)∥Lp(Ω)p we have infR∈K∥Du−R∥Lp(Ω′)p≤M\veps1/p provided u satisfies the inequality ∥D2u∥Lq(Ω)q≤a\veps1−q. Our main result holds whenever m=2, and also for {\em generic} m≤n in every dimension n≥3, as long as the wells SO(n)A1,...,SO(n)Am satisfy a certain connectivity condition. These conclusions are mostly known when n=2, and they are new for n≥3.