                 }
             }
             counterArray[arrayWithMinElementIndex] += 1
+            
+            if isSeriesEven && index == requiredElementIndex {
+                minCurrentElement! += previousElementInSeries
+            }
             index += 1
         }
         

    var totalElementCount = 0
    arrays.forEach({ totalElementCount = totalElementCount + $0.count})
    
    func getElementAtIndex(requiredElementIndex : Int) -> Int?{
        var index = 0
        var minCurrentElement : Int?
        var arrayWithMinElementIndex = 0
        var counterArray = Array(repeating: 0, count: arrays.count)
        while index < requiredElementIndex {
            minCurrentElement = Int.max
            for currentArrayIndex in 0 ..< arrays.count {
                if arrays[currentArrayIndex].count <= counterArray[currentArrayIndex]{

    
    
    if totalElementCount % 2 == 0 {
        return Double(getElementAtIndex(requiredElementIndex: totalElementCount/2, isSeriesEven: true)!) / 2.0
    }else{
        return Double(getElementAtIndex(requiredElementIndex: totalElementCount/2)!)
    }
}
