private static float calculatePriceMain(int[] seriesCounts) {
		Arrays.sort(seriesCounts);
		
		int numBooks = 0;
		int numUniqueBooks = 0;
		
		for(int series = 0; series < seriesSize; series++) {
			numBooks += seriesCounts[series];
			
			if(seriesCounts[series] > 0) {
				numUniqueBooks++;
			}
		}
		
		if(numBooks == numUniqueBooks) {
			return prices[numBooks];
		}
		
		float minPrice = numBooks * unitPrice;
		int numCombinations = (int) (Math.pow(2, numUniqueBooks));
		
		for(int combination = 1; combination < numCombinations; combination++) {
			int[] seriesCountsCopy = seriesCounts.clone();
			int[] decrementals = new int[seriesSize];
			int combinationCopy = combination;
			
			for(int i = seriesSize - 1; i >= 0; i--) {
				int decremental = combinationCopy & 1;
				decrementals[i] = decremental; 
				
				combinationCopy = combinationCopy >> 1;
			}
			
			for(int i = 0; i < seriesSize; i++) {
				seriesCountsCopy[i] = seriesCountsCopy[i] - decrementals[i];
			}
			
			minPrice = Math.min(minPrice, 
					calculatePriceMain(seriesCountsCopy) + 
					calculatePriceMain(decrementals));
		}
		
		return minPrice;
	}