1.

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

/**
 * Problem #10107 - What Is The Median -
 * http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=13&page=show_problem&problem=1048
 *
 * Status : Accepted
 * Runtime: 2.664
 */

/**
 * @author Mariya Vlaseva
 *
 */
public class Main {


    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> numbers = new ArrayList<Integer>();
       
        while(sc.hasNext()) {
            numbers.add(sc.nextInt());
            Collections.sort(numbers);   
            System.out.println(median(numbers));
        }
    }
   
    public static int median(ArrayList<Integer> m) {
        int middle = m.size()/2;  // subscript of middle element
        if (m.size()%2 == 1) {
            // Odd number of elements -- return the middle one.
            return m.get(middle);
        } else {
           // Even number -- return average of middle two
           // Must cast the numbers to double before dividing.
           return (m.get(middle-1) + m.get(middle) )/ 2;
        }
    }//end method median

}