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

                }
            }
            counterArray[arrayWithMinElementIndex] += 1
            index += 1
        }
        

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