In an embassy of a well-known kingdom an electronic queue is organised. Every person who comes to the embassy, needs to make the following three actions: show the ID, pay money to the cashier and be fingerprinted. Besides, the actions should be performed in the given order.

For each action several separate windows are singled out: k1 separate windows for the first action (the first type windows), k2 windows for the second one (the second type windows), and k3 for the third one (the third type windows). The service time for one person in any of the first type window equals to t1. Similarly, it takes t2 time to serve a person in any of the second type windows. And it takes t3 to serve one person in any of the third type windows. Thus, the service time depends only on the window type and is independent from the person who is applying for visa.

At some moment n people come to the embassy, the i-th person comes at the moment of time ci. The person is registered under some number. After that he sits in the hall and waits for his number to be shown on a special board. Besides the person's number the board shows the number of the window where one should go and the person goes there immediately. Let's consider that the time needed to approach the window is negligible. The table can show information for no more than one person at a time. The electronic queue works so as to immediately start working with the person who has approached the window, as there are no other people in front of the window.

The Client Service Quality inspectors noticed that several people spend too much time in the embassy (this is particularly tiresome as the embassy has no mobile phone reception and 3G). It was decided to organise the system so that the largest time a person spends in the embassy were minimum. Help the inspectors organise the queue. Consider that all actions except for being served in at the window, happen instantly.

Input

The first line contains three space-separated integers k1, k2, k3 (1 ≤ ki ≤ 109), they are the number of windows of the first, second and third type correspondingly.

The second line contains three space-separated integers t1, t2, t3 (1 ≤ ti ≤ 105), they are the periods of time needed to serve one person in the window of the first, second and third type correspondingly. 

The third line contains an integer n (1 ≤ n ≤ 105), it is the number of people.

The fourth line contains n space-separated integers ci (1 ≤ ci ≤ 109) in the non-decreasing order; ci is the time when the person number i comes to the embassy.

Output

Print the single number, the maximum time a person will spend in the embassy if the queue is organized optimally.

Please, do not use the %lld specificator to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams (also you may use the %I64d specificator).

Examples

Input

1 1 1
1 1 1
5
1 1 1 1 1


Output

7


Input

2 1 1
5 1 1
5
1 2 3 3 5


Output

13

Note

In the first test 5 people come simultaneously at the moment of time equal to 1. There is one window of every type, it takes 1 unit of time to be served at each window. That's why the maximal time a person spends in the embassy is the time needed to be served at the windows (3 units of time) plus the time the last person who comes to the first window waits (4 units of time).

Windows in the second test work like this:

The first window of the first type: [1, 6) — the first person, [6, 11) — third person, [11, 16) — fifth person

The second window of the first type: [2, 7) — the second person, [7, 12) — the fourth person

The only second type window: [6, 7) — first, [7, 8) — second, [11, 12) — third, [12, 13) — fourth, [16, 17) — fifth

The only third type window: [7, 8) — first, [8, 9) — second, [12, 13) — third, [13, 14) — fourth, [17, 18) — fifth

We can see that it takes most time to serve the fifth person.
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.PriorityQueue;
import java.util.Collection;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedOutputStream;
import java.util.AbstractCollection;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author An Almost Retired Guy
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int k1 = in.nextInt(), k2 = in.nextInt(), k3 = in.nextInt();
            int t1 = in.nextInt(), t2 = in.nextInt(), t3 = in.nextInt();
            int n = in.nextInt();
            k1 = Math.min(k1, n);
            k2 = Math.min(k2, n);
            k3 = Math.min(k3, n);
            int[] C = in.nextIntArray(n);
            long ans = 0;
            EzLongArrayDeque queue1 = new EzLongArrayDeque(new long[k1]), queue2 = new EzLongArrayDeque(new long[k2]), queue3 = new EzLongArrayDeque(new long[k3]);
            PriorityQueue<Event> pq = new PriorityQueue<>();
            for (int i = 0; i < n; i++) pq.add(new Event(i, 0, C[i]));
            while (!pq.isEmpty()) {
                Event pair = pq.poll();
                long time = pair.time;
                int id = pair.id, type = pair.type;
                if (type == 0) {
                    time = Math.max(time, queue1.removeFirst()) + t1;
                    queue1.addLast(time);
                    pq.add(new Event(id, 1, time));
                } else if (type == 1) {
                    time = Math.max(time, queue2.removeFirst()) + t2;
                    queue2.addLast(time);
                    pq.add(new Event(id, 2, time));
                } else if (type == 2) {
                    time = Math.max(time, queue3.removeFirst()) + t3;
                    queue3.addLast(time);
                    pq.add(new Event(id, 3, time));
                } else ans = Math.max(ans, time - C[id]);
            }
            out.println(ans);
        }

        class Event implements Comparable<Event> {
            int id;
            int type;
            long time;

            Event(int id, int type, long time) {
                this.id = id;
                this.type = type;
                this.time = time;
            }


            public int compareTo(Event that) {
                return Long.compare(this.time, that.time);
            }


            public String toString() {
                return "(" + id + " " + type + " " + time + ")";
            }

        }

    }

    static interface EzLongIterator {
        boolean hasNext();

        long next();

    }

    static interface EzLongCollection {
        int size();

        EzLongIterator iterator();

        boolean equals(Object object);

        int hashCode();

        String toString();

    }

    static interface EzLongQueue extends EzLongCollection {
        int size();

        EzLongIterator iterator();

        boolean equals(Object object);

        int hashCode();

        String toString();

    }

    static interface EzLongStack extends EzLongCollection {
        int size();

        EzLongIterator iterator();

        boolean equals(Object object);

        int hashCode();

        String toString();

    }

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(new BufferedOutputStream(outputStream));
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public void close() {
            super.close();
        }

    }

    static class EzLongArrayDeque implements EzLongDeque, EzLongList {
        private static final int DEFAULT_CAPACITY = 8;
        private static final int HASHCODE_INITIAL_VALUE = 0x811c9dc5;
        private static final int HASHCODE_MULTIPLIER = 0x01000193;
        private long[] deque;
        private int size;
        private int head;
        private int tail;
        private int mask;

        public EzLongArrayDeque() {
            this(DEFAULT_CAPACITY);
        }

        public EzLongArrayDeque(int capacity) {
            if (capacity < 0) {
                throw new IllegalArgumentException("Capacity must be non-negative");
            }
            if (capacity < 1) {
                capacity = 1;
            }
            if ((capacity & (capacity - 1)) != 0) {
                capacity = Integer.highestOneBit(capacity) << 1;
            }
            // Capacity is a power of 2 now
            deque = new long[capacity];
            size = 0;
            head = 0;
            tail = 0;
            mask = deque.length - 1;
        }

        public EzLongArrayDeque(EzLongCollection collection) {
            this(collection.size() + 1);
            for (EzLongIterator iterator = collection.iterator(); iterator.hasNext(); ) {
                deque[tail++] = iterator.next();
            }
            size = collection.size();
        }

        public EzLongArrayDeque(long[] srcArray) {
            this(srcArray.length + 1);
            System.arraycopy(srcArray, 0, deque, 0, srcArray.length);
            tail = srcArray.length;
            size = srcArray.length;
        }

        public EzLongArrayDeque(Collection<Long> javaCollection) {
            this(javaCollection.size() + 1);
            for (long element : javaCollection) {
                deque[tail++] = element;
            }
            size = javaCollection.size();
        }


        public int size() {
            return size;
        }


        public EzLongIterator iterator() {
            return new EzLongArrayDequeIterator();
        }


        public void addLast(long element) {
            deque[tail] = element;
            tail = (tail + 1) & mask;
            size++;
            if (size == deque.length) {
                enlarge();
            }
        }


        public long removeFirst() {
            if (size == 0) {
                throw new NoSuchElementException("Trying to call removeFirst() on empty ArrayDeque");
            }
            final long removedElement = deque[head];
            size--;
            head = (head + 1) & mask;
            return removedElement;
        }

        private void enlarge() {
            int newSize = (size << 1);
            long[] newArray = new long[newSize];
            System.arraycopy(deque, head, newArray, 0, deque.length - head);
            System.arraycopy(deque, 0, newArray, deque.length - tail, tail);
            deque = newArray;
            head = 0;
            tail = size;
            mask = deque.length - 1;
        }


        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            EzLongArrayDeque that = (EzLongArrayDeque) o;

            if (size != that.size) {
                return false;
            }
            for (int i = head, j = that.head; i != tail; i = (i + 1) & mask, j = (j + 1) & that.mask) {
                if (deque[i] != that.deque[j]) {
                    return false;
                }
            }
            return true;
        }


        public int hashCode() {
            int hash = HASHCODE_INITIAL_VALUE;
            for (int i = head; i != tail; i = (i + 1) & mask) {
                hash = (hash ^ PrimitiveHashCalculator.getHash(deque[i])) * HASHCODE_MULTIPLIER;
            }
            return hash;
        }


        public String toString() {
            StringBuilder sb = new StringBuilder();
            sb.append('[');
            for (int i = head; i != tail; i = (i + 1) & mask) {
                if (i != head) {
                    sb.append(", ");
                }
                sb.append(deque[i]);
            }
            sb.append(']');
            return sb.toString();
        }

        private class EzLongArrayDequeIterator implements EzLongIterator {
            private int curIndex = head;


            public boolean hasNext() {
                return curIndex != tail;
            }


            public long next() {
                if (curIndex == tail) {
                    throw new NoSuchElementException("Iterator doesn't have more elements");
                }
                final long result = deque[curIndex];
                curIndex = (curIndex + 1) & mask;
                return result;
            }

        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                st = new StringTokenizer(nextLine());
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        public String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

    }

    static final class PrimitiveHashCalculator {
        private PrimitiveHashCalculator() {
        }

        public static int getHash(long x) {
            return (int) x ^ (int) (x >>> 32);
        }

    }

    static interface EzLongDeque extends EzLongQueue, EzLongStack {
        int size();

        EzLongIterator iterator();

        boolean equals(Object object);

        int hashCode();

        String toString();

    }

    static interface EzLongList extends EzLongCollection {
        int size();

        EzLongIterator iterator();

        boolean equals(Object object);

        int hashCode();

        String toString();

    }
}

