/* package whatever; // don't place package name! */

import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

public class Main {

  static List c(final int[] f) {
    final LinkedList c = new LinkedList();
    for (final int i : f) {
      c.add(i);
    }
    for (; c.size() > 5;) {
      c.removeLastOccurrence(Collections.min(c));
    }
    return c;
  }

  public static void main(final String[] a) {
    System.out.println(Arrays.toString(c(new int[]{ 0, 2, 5, 4, 0, 1, 0 }).toArray()));
    System.out.println(Arrays.toString(c(new int[]{ 2, 1, 1, 5, 3, 6 }).toArray()));
    System.out.println(Arrays.toString(c(new int[]{ 0, 4, 5 }).toArray()));
    System.out.println(Arrays.toString(c(new int[]{ 1, 1, 5, 1, 1, 5 }).toArray()));
    System.out.println(Arrays.toString(c(new int[]{ 0, 2, 0, 0, 0, 0, 0, 0 }).toArray()));
    System.out.println(Arrays.toString(c(new int[]{ 0, 0, 0, 0, 1, 0, 0, 0, 0 }).toArray()));
    System.out.println(Arrays.toString(
        c(new int[]{ 6, 3, 2, 0, 69, 22, 0, 37, 0, 2, 1, 0, 0, 0, 5, 0, 1, 2, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 2 })
            .toArray()));
  }
}