#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>

using namespace std;

int N;
int S;
int storage;
int average = 0;
int sum = 0;

int i;
int j;
int num;

void resort(int* nums) {
    for(j = 0; j < N; j++) {
        for(i = 1; i < N; i++) {
            if(nums[i-1] > nums[i]) {
                num = nums[i];
                nums[i] = nums[i-1];
                nums[i-1] = num;
            }
        }
    }

    i = 0;
    j = 0;
}

void oil(int* weeks) {
    for(i = 0; i < N; i++) {
        if(N%2 == 1 && N/2 == i) {
            continue;
        }
        if(weeks[i] < average) {
            sum -= weeks[i];
        }
        if(weeks[i] > average) {
            sum += weeks[i];
        }
    }
    sum -= storage;
}

int main() {
    scanf("%d", &N);
    scanf("%d", &S);
    storage = N*S;

    int weeks[N];
    int value;
    for(i = 0; i < N; i++) {
        scanf("%d", &value);
        weeks[i] = value;
        average += value;
    }
    average = average / N;

    resort(weeks);
    oil(weeks);
    printf("%d", sum);
    return 0;
}