#include <bits/stdc++.h>
#define int long long
using namespace std;
constexpr int N = 100010;
int n, k, p, a[N], b[N], ans, z;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
freopen("defeat.in", "r", stdin);
freopen("defeat.out", "w", stdout);
cin >> n >> k >> p;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) {
a[i] += z;
if (a[i] < k) {
ans += k - a[i];
z += k - a[i];
} else if (a[i] > k) {
ans += a[i] - k;
z -= a[i] - k;
}
}
cout << ans;
return 0;
}