#include <bits/stdc++.h>
using namespace std;
int arr[10000 + 10];
int main() {
  int k, n1, n2, n3, t1, t2, t3;
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  for (int i = 1; i <= k; i++) {
    int b1, b2, b3;
    b1 = b2 = b3 = 0;
    int a1 = max(i - n1, 0);
    int a2 = max(i - n2, 0);
    int a3 = max(i - n3, 0);
    if (a1 != 0) b1 = arr[a1] + t1;
    if (a2 != 0) b2 = arr[a2] + t2;
    if (a3 != 0) b3 = arr[a3] + t3;
    int maxix = max(b1, b2);
    maxix = max(maxix, b3);
    arr[i] = maxix;
  }
  cout << arr[k] + t1 + t2 + t3;
  return 0;
}
