#include <bits/stdc++.h>
constexpr int maxn = 400010;
long long a[maxn], s[maxn], v[maxn];
int q[maxn], h, t;
int main() {
  int n;
  long long c;
  std::cin >> n >> c;
  std::copy(std::istream_iterator<int>(std::cin), std::istream_iterator<int>(),
            a + 1);
  std::partial_sum(a + 1, a + n + n, a + 1);
  h = 0, t = -1;
  for (int i = 1; i <= n; ++i) {
    v[i] = s[i - 1] - a[i + i - 2];
    while (h <= t && v[q[t]] <= v[i]) --t;
    q[++t] = i;
    while (h <= t && a[i + i - 1] - a[q[h] + q[h] - 2] >= c) ++h;
    s[i] = std::max(h ? c + s[q[h - 1] - 1] : 0,
                    h <= t ? a[i + i - 1] + v[q[h]] : 0);
  }
  std::cout << s[n] << std::endl;
}
