#include #include #include using namespace std; #define NSTATION_MAX 10000 #define INFTY INT_MAX int L1, L2, L3; int C1, C2, C3; int nstation; int from, to; int D[NSTATION_MAX+1], M[NSTATION_MAX+1]; int main() { cin >> L1 >> L2 >> L3 >> C1 >> C2 >> C3; cin >> nstation; cin >> from >> to; if ( from > to ) swap(from, to); D[1] = 0; for ( int i = 2; i <= nstation; i++ ) cin >> D[i]; for ( int n = from; n <= to; n++ ) M[n] = INFTY; M[from] = 0; int l1 = from, l2 = from, l3 = from; for ( int n = from; n <= to; n++ ) { while ( D[n] - D[l1] > L1 ) l1++; while ( D[n] - D[l2] > L2 ) l2++; while ( D[n] - D[l3] > L3 ) l3++; if ( l1 < n ) M[n] = min(M[n], M[l1] + C1); if ( l2 < n ) M[n] = min(M[n], M[l2] + C2); if ( l3 < n ) M[n] = min(M[n], M[l3] + C3); } cout << M[to] << endl; return 0; }