//Shirasu Azusa 2024.03 #include #define fi first #define se second #define eb emplace_back #define mp make_pair using namespace std; typedef long double ld; typedef long long ll; typedef unsigned long long ull; typedef __int128 i128; template T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);} template T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);} template bool chmax(T &a,const S b) {return (a bool chmin(T &a,const S b) {return (a>b?a=b,1:0);} int popcnt(int x) {return __builtin_popcount(x);} int popcnt(ll x) {return __builtin_popcountll(x);} int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));} int topbit(ll x) {return (x==0?-1:63-__builtin_clzll(x));} int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));} int lowbit(ll x) {return (x==0?-1:__builtin_ctzll(x));} #define int long long #define rep(i,a,b) for(int i=(a);i<=(b);i++) #define per(i,a,b) for(int i=(a);i>=(b);i--) typedef pair pii; typedef vector vi; typedef vector vp; typedef tuple tiii; int read() { int x=0,w=1; char c=getchar(); while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();} while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();} return x*w; } const int N=2005,inf=0x3f3f3f3f3f3f3f3f; int n,x,y,m,d,f[N][2*N],g[N],ans=inf,a[N],b[N],s[N]; int calc(int t) { return max(0ll,t%d-x); } int J(int i,int t) { int p=t-g[i]; assert(p>=0); return p/d*2+(p%d>=x); } int T(int i,int j) { return g[i]+j/2*d+(j&1)*x; } signed main() { n=read()-1, x=read(), y=read(), m=read(), d=x+y; rep(i,1,n) a[i]=read(); per(i,n,1) s[i]=s[i+1]+a[i]; memset(f,0x3f,sizeof(f)); f[0][0]=0; int zz=0; rep(i,1,n) { g[i]=g[i-1]+a[i]; if(calc(g[i])) g[i]-=calc(g[i]); } rep(i,1,n) g[i]=g[i]/d*d; //rep(i,1,n) cout<x) { int y=J(p0,T(i-1,j)+(q0+d-1)/d*d); //cout<<" "<x) { int y=J(p1,T(i-1,j-1)+(q1+d-1)/d*d); //cout<<"UPD "<rem) continue; if(j%2==0) r=H-min(s[i+1]-W,rem-f[i][j]); else r=Hx-min(s[i+1]-Wx,rem-f[i][j]); //cout<