Source Code
/*############################################################################################################
########################################## >>>> Diaa12360 <<<< ###############################################
###########################################   Just Nothing   #################################################
####################################  If You Need it, Fight For IT;  #########################################
###############################################.-. 1 5 9 2 .-.################################################
############################################################################################################*/

import java.io.*;
import java.util.*;
import java.util.function.Function;

public class Solution {
    // if we have the same number we stop and print

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//        BufferedReader in = new BufferedReader(new FileReader("src/input"));
        StringBuilder out = new StringBuilder();
        StringTokenizer tk;
        int t = ints(in.readLine());
        while (t-- > 0) {
            int n = ints(in.readLine());
            ArrayList<Integer> arr = new ArrayList<>();
            tk = new StringTokenizer(in.readLine());
            for (int i = 0; i < n; i++) {
                arr.add(ints(tk.nextToken()));
            }
            while (!arr.isEmpty() && arr.get(0) < av(arr))
                arr.remove(0);
            out.append(arr).append('\n');
        }
        System.out.print(out);
    }

    static double av(ArrayList<Integer> arr) {
        int sum = 0;
        for (Integer integer : arr) {
            sum += integer;
        }
        return sum*1.0 / arr.size();
    }

    static int ints(String s) {
        return Integer.parseInt(s);
    }

    static long ll(String s) {
        return Long.parseLong(s);
    }

    static int[] readArray(String s, int n) {
        StringTokenizer tk = new StringTokenizer(s);
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
            arr[i] = ints(tk.nextToken());
        return arr;
    }

    static <T, E> Map<T, E> createMapFromList(List<T> l, Function<T, E> fun) {
        Map<T, E> mp = new HashMap<>();
        for (T x : l) {
            mp.put(x, fun.apply(x));
        }
        return mp;
    }

    static int[] readArray(String s) {
        StringTokenizer tk = new StringTokenizer(s);
        int[] arr = new int[tk.countTokens()];
        for (int i = 0; i < arr.length; i++)
            arr[i] = ints(tk.nextToken());
        return arr;
    }

    static void printArray(char[][] arr, StringBuilder out) {
        out.append("YES").append('\n');
        for (char[] chars : arr) {
            for (char c : chars) {
                out.append(c);
            }
            out.append('\n');
        }
    }
}

class ArrayStack<E> {
    public static final int CAPACITY = 1000;
    private E[] data;
    private int t = -1;

    public ArrayStack() {
        this(CAPACITY);
    }

    public ArrayStack(int capacity) {
        data = (E[]) new Object[capacity];
    }

    public int size() {
        return t + 1;
    }

    public boolean isEmpty() {
        return t == -1;
    }

    public E push(E e) throws IllegalStateException {
        if (size() == data.length) throw new IllegalStateException("Stack is full");
        data[++t] = e;
        return e;
    }

    public E peek() {
        return isEmpty() ? null : data[t];
    }

    public E pop() {
        if (isEmpty())
            return null;
        E d = data[t];
        data[t] = null;
        t--;
        return d;
    }
}

class points {
    long h;
    long k;

    points(long h, long k) {
        this.h = h;
        this.k = k;
    }


    @Override
    public String toString() {
        return "points{" +
                "h=" + h +
                ", k=" + k +
                '}';
    }
}
/*
1 1
1 2
1 3 / 2 2
1 4 / 3 2
3 3 / 2 4 / 1 5
1 6 / 2 5 / 4 3
1 7 / 2 6 / 3 5 / 4 4
1 8 / 2 7 / 3 6 / 4 5
1 9 / 2 8 / 3 7 / 4 6 / 5 5
1 10/ 2 9 / 3 8 / 4 7 / 5 6

 */
Copy
To-do List Diaa12360
Java 11
122 ms
10.9 MB
Wrong Answer