Mode of an array is the most frequent element, mode frequency is frequency of most frequent element.
For example, $$$[1,3,5,5]$$$ has mode $$$5$$$ and it's frequency is $$$2$$$ so mode frequency of this array is $$$2$$$.
For an array of length $$$N$$$ we need to find sum of mode frequency of all subarrays.
Is there any way to do this better than $$$O(N^2)$$$?