Optimization Theory for n-Set Functions