Function that trims array by percents