N, K = map(int, input().split())
A = list(map(int, input().split()))

frequency = {}
best = 81
k_original = K
k_default = K
prev_lower_bound, prev_upper_bound = None, None

for A_i in A:
    frequency[A_i] = frequency.get(A_i, 0) + 1

for lower_bound in sorted(frequency):
    if prev_lower_bound != None:
        k_default -= frequency[prev_lower_bound]

        if k_default < 0:
            break

    K = k_default

    for upper_bound in sorted(frequency, reverse=True):
        if upper_bound < lower_bound:
            break
        elif K == 0 or K < frequency[upper_bound]:
            attempt = upper_bound ** 2 - lower_bound ** 2
            if attempt < best:
                best = attempt
            break
        K -= frequency[upper_bound]

    prev_lower_bound = lower_bound

k_default = k_original

for upper_bound in sorted(frequency, reverse=True):
    if prev_upper_bound != None:
        k_default -= frequency[prev_upper_bound]

        if k_default < 0:
            break

    K = k_default

    for lower_bound in sorted(frequency):
        if lower_bound > upper_bound:
            break
        elif K == 0 or K < frequency[lower_bound]:
            attempt = upper_bound ** 2 - lower_bound ** 2
            if attempt < best:
                best = attempt
            break
        K -= frequency[lower_bound]

    prev_upper_bound = upper_bound

print(best, end="")