Remove the occurences of an element from array if it occurs more than n times
It's been said multiple times but you should avoid one letter variable most of the time.

Class name arr is also no good. It's recommended that class name follows camel case convention and using abbreviation is often considered bad.  

Don't code something in your main as it makes it harder to test your code.
Putting it in an outside function makes for a clearer code :

public static int[] removeOccurencesFromArray(final int[] array, final long maxOccurence) {
    // TODO
}


Array have an "old-school" feel and I'd avoid them if possible. Consider using List (and especially ArrayList) for those kind of use case, thus transforming previous method in :

public static List&lt;Integer&gt; removeOccurencesFromList(final List&lt;Integer&gt; list, final long maxOccurence) {
    // TODO
}




Now, onto the main course :

I find your algorithm overly complex. :/
It's also higly "procedural" IMO, in modern computing we'd rather "tell" the program to do something instead of manipulating everything by ourselves.

Julien Rousé has shown a nice and short solution in another answer... which is probably faster than mine but please bear with me :)

(After rereading my answer, I see that I used some Java 8 tricks that may feel overwhelming if you are a beginner, if you are new to programming I'd recommend to not consider my solution)

Let's try to solve your problem step by step :  

Here is a simple solution I came up with (almost the same as Julien Rousé)
1) count the number of occurences within your array... you end up with a structure linking all elements with the number of occurence... it's usually called a bag, while there are some java library that supports this structure let's keep things simple and use a Map
2) if any occurences count is greater than the maxOccurence parameter then it should be set to maxOccurence
3) for each elements in your array, print it if the number of occurences is greater than 0 and reduce the number of elements in your bag

Let's dig a bit in java 8... surely there's a tool for us in there.
We are looking for something that'd allow us to "tell" instead of creating everything by hand.

In the Collectors util class (https://docs.oracle.com/javase/8/docs/api/java/util/stream/Collectors.html), we can find some really fancy tools. For our use case, groupingBy and counting sounds useful.

groupingBy allows you to transform a stream of data into a map where the key is found using the first parameter.
counting counts the number of input elements (from Javadoc).

list.stream().collect(Collectors.groupingBy(element -&gt; element, Collectors.counting()));


With this simple line, we now have the number of occurence of each elements of your list.

This is still not enough as we want to consider the maximum number of occurences.

We want to have the number of occurence if it's below a threshold.
Collectors (again) comes to the rescue :

list.stream().collect(Collectors.groupingBy(element -&gt; element,
            Collectors.collectingAndThen(Collectors.counting(), v -&gt; Math.min(v, maxOccurence))));


So we are counting unless we have more than maxOccurence, in which case the min will always give us maxOccurence as a result.
That's not very palatable though IMO, I'll use static import to make it cleaner. Let's also not forget to store the result.

    Map&lt;Integer, Long&gt; value = list.stream().collect(groupingBy(element -&gt; element,
            collectingAndThen(counting(), v -&gt; Math.min(v, maxOccurence))));


We can now easily compute the result :

    List&lt;Integer&gt; result = new ArrayList&lt;&gt;();
    for (Integer element : list) {
        long remaining = value.get(element);
        if (remaining &gt; 0) {
            value.put(element, remaining - 1);
            result.add(element);
        }
    }

    return result;


If you really want to have an array at the end, use the toArray method ;)