import java.io.*; import java.math.*; import java.util.*; public class Main_yukicoder409 { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); long a = sc.nextInt(); long b = sc.nextInt(); long w = sc.nextInt(); int[] d = new int[n]; for (int i = 0; i < n; i++) { d[i] = sc.nextInt(); } long[] dp = new long[n + 1]; ConvexHullTrick cht = new ConvexHullTrick(n); for (int i = 1; i <= n; i++) { int j = i - 1; cht.add(-b * j, dp[j] + a * j + b * j * (j + 1) / 2); dp[i] = cht.query(i) + d[i - 1] - a * (i - 1) + b * i * (i - 1) / 2; } long ans = Long.MAX_VALUE; for (int i = 0; i <= n; i++) { long tmp = dp[i] - a * (n - i) + b * (n - i) * (n - i + 1) / 2; // pr.printf("%d %d %d\n", i, tmp, ans); ans = Math.min(ans, tmp); } pr.println(ans + w); } private static class ConvexHullTrick { // int n; int cnt; long[] aa; long[] bb; // long[] dn; // long[] dd; double[] dd; NavigableSet f; NavigableSet d; ConvexHullTrick(int n) { // this.n = n; cnt = 0; aa = new long[n]; bb = new long[n]; // dn = new long[n + 1]; // dd = new long[n + 1]; dd = new double[n + 1]; f = new TreeSet<>((x, y) -> {return aa[x] == aa[y] ? Long.compare(bb[x], bb[y]) : Long.compare(aa[y], aa[x]);}); d = new TreeSet<>((x, y) -> {return Double.compare(dd[x], dd[y]);}); } private void add(long a, long b) { aa[cnt] = a; bb[cnt] = b; int curr = cnt++; if (f.contains(curr)) { return; } Integer prev = f.lower(curr); Integer next = f.higher(curr); if (!check(prev, curr, next)) { return; } while (prev != null) { Integer pprev = f.lower(prev); if (check(pprev, prev, curr)) { break; } f.remove(prev); d.remove(prev); prev = pprev; } while (next != null) { Integer nnext = f.higher(next); if (check(curr, next, nnext)) { break; } f.remove(next); d.remove(next); next = nnext; } if (prev == null) { dd[curr] = Double.NEGATIVE_INFINITY; f.add(curr); d.add(curr); } else { dd[curr] = (double)(bb[curr] - bb[prev]) / (aa[prev] - aa[curr]); f.add(curr); d.add(curr); } if (next != null) { d.remove(next); dd[next] = (double)(bb[next] - bb[curr]) / (aa[curr] - aa[next]); d.add(next); } } private long query(long x) { dd[cnt] = (double)x; Integer mini = d.lower(cnt); if (mini == null) { pr.printf("%d %f\n", x, dd[cnt]); pr.flush(); } return fx(mini, x); } private long fx(int i, long x) { return aa[i] * x + bb[i]; } private boolean check(Integer prev, Integer curr, Integer next) { if (prev == null || next == null) { return true; } // return bb[next] * aa[prev] - bb[prev] * aa[next] > aa[curr] * bb[next] - aa[curr] * bb[prev] + bb[curr] * aa[prev] - bb[curr] * aa[next]; BigInteger a1 = BigInteger.valueOf(aa[prev]); BigInteger a2 = BigInteger.valueOf(aa[curr]); BigInteger a3 = BigInteger.valueOf(aa[next]); BigInteger b1 = BigInteger.valueOf(bb[prev]); BigInteger b2 = BigInteger.valueOf(bb[curr]); BigInteger b3 = BigInteger.valueOf(bb[next]); return b3.multiply(a1).subtract(b1.multiply(a3)).compareTo(a2.multiply(b3).subtract(a2.multiply(b1)).add(b2.multiply(a1)).subtract(b2.multiply(a3))) > 0; } } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } private boolean isPrintable(int ch) { return ch >= '!' && ch <= '~'; } private boolean isCRLF(int ch) { return ch == '\n' || ch == '\r' || ch == -1; } private int nextPrintable() { try { int ch; while (!isPrintable(ch = br.read())) { if (ch == -1) { throw new NoSuchElementException(); } } return ch; } catch (IOException e) { throw new NoSuchElementException(); } } String next() { try { int ch = nextPrintable(); StringBuilder sb = new StringBuilder(); do { sb.appendCodePoint(ch); } while (isPrintable(ch = br.read())); return sb.toString(); } catch (IOException e) { throw new NoSuchElementException(); } } int nextInt() { try { // parseInt from Integer.parseInt() boolean negative = false; int res = 0; int limit = -Integer.MAX_VALUE; int radix = 10; int fc = nextPrintable(); if (fc < '0') { if (fc == '-') { negative = true; limit = Integer.MIN_VALUE; } else if (fc != '+') { throw new NumberFormatException(); } fc = br.read(); } int multmin = limit / radix; int ch = fc; do { int digit = ch - '0'; if (digit < 0 || digit >= radix) { throw new NumberFormatException(); } if (res < multmin) { throw new NumberFormatException(); } res *= radix; if (res < limit + digit) { throw new NumberFormatException(); } res -= digit; } while (isPrintable(ch = br.read())); return negative ? res : -res; } catch (IOException e) { throw new NoSuchElementException(); } } long nextLong() { try { // parseLong from Long.parseLong() boolean negative = false; long res = 0; long limit = -Long.MAX_VALUE; int radix = 10; int fc = nextPrintable(); if (fc < '0') { if (fc == '-') { negative = true; limit = Long.MIN_VALUE; } else if (fc != '+') { throw new NumberFormatException(); } fc = br.read(); } long multmin = limit / radix; int ch = fc; do { int digit = ch - '0'; if (digit < 0 || digit >= radix) { throw new NumberFormatException(); } if (res < multmin) { throw new NumberFormatException(); } res *= radix; if (res < limit + digit) { throw new NumberFormatException(); } res -= digit; } while (isPrintable(ch = br.read())); return negative ? res : -res; } catch (IOException e) { throw new NoSuchElementException(); } } float nextFloat() { return Float.parseFloat(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { try { int ch; while (isCRLF(ch = br.read())) { if (ch == -1) { throw new NoSuchElementException(); } } StringBuilder sb = new StringBuilder(); do { sb.appendCodePoint(ch); } while (!isCRLF(ch = br.read())); return sb.toString(); } catch (IOException e) { throw new NoSuchElementException(); } } void close() { try { br.close(); } catch (IOException e) { // throw new NoSuchElementException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }