#pragma region Region_1

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
using ll = long long;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VP = vector<P>;
#define MOD 1000000007
const int INF = 1e9 + 10;

template <class T, class C> void chmax(T& a, C b) {
    if (a <= b) a = b;
}
template <class T, class C> void chmin(T& a, C b) {
    if (a >= b) a = b;
}

// const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
// const int dx[]{0, 1, 0, -1}, dy[]{1, 0, -1, 0};

template <class T> T sum(const vector<T>& v) {
    T res = 0;
    for (size_t i = 0; i < v.size(); ++i) res += v[i];
    return res;
}

/////////////////////////////////////////////////////////
// print like python
// https://qiita.com/Lily0727K/items/06cb1d6da8a436369eed
/////////////////////////////////////////////////////////
void print() { cout << endl; }

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << " ";
    print(forward<Tail>(tail)...);
}

template <class T> void print(vector<T>& vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << " ";
    }
    cout << endl;
}

template <class T> void print(vector<vector<T>>& df) {
    for (auto& vec : df) {
        print(vec);
    }
}

#pragma endregion Region_1
/////////////////////////////////////////////////////////

int main() {
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::cout << std::setprecision(15);
    //////////////////////////////////////////
    int n,k,m;
    cin >> n >> k >> m;
    VI A(n-1);
    ll tot=0;
    rep(i,n-1){
        cin >> A[i];
        tot += A[i];
    }
    if(tot - (n*m)>=0){
        print(0);
    }else if(tot + k <(n*m)){
        print(-1);
    }else{
        print((n*m)-tot);
    }

    return 0;
}


// Problem : D - Snuke Prime
// Contest : AtCoder - AtCoder Beginner Contest 188
// URL : https://atcoder.jp/contests/abc188/tasks/abc188_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、 
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)

#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy

void solve()
{
	ll N,C;cin>>N>>C;
	vl pt;
	map<ll,ll> st,en;
	F0R(x,N)
	{
		ll a,b,c;cin>>a>>b>>c;
		st[a]+=c;
		en[b]+=c;
		pt.pb(a);
		pt.pb(b);//?
	}
	sort(all(pt));
	pt.erase(unique(all(pt)),pt.end());
	ll sum=0,ans=0;
	F0R(x,sz(pt))
	{
		if(x!=0)
		{
			ans+=(pt[x]-pt[x-1]-1)*min(C,sum);
		}
		if(st.count(pt[x]))
			sum+=st[pt[x]];
		ans+=min(C,sum);
		if(en.count(pt[x]))
			sum-=en[pt[x]];
	}
	cout<<ans;
}

int main() 
{
	// think two times, so you won't have to code three times
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int Test_case=1;
	// cin>>Test_case;
	while(Test_case--!=0)
	{
		solve();
	}
	return 0;
}

// read the question correctly (ll vs int)
// template by bqi343