Specialized code for problem with 6n flops.