Write code to find the frequency of elements in an array.
Implement frequency_elements(arr), where arr is a list of strings. Return a dictionary mapping each distinct element to its number of occurrences. The result should include every distinct element and preserve the order in which distinct elements first appear.
def frequency_elements(arr):