#include <bits/stdc++.h>
using namespace std;
const int inf = int(1e9);
const double eps = 1e-9;
int tm1[1010], tm2[1010], tm3[1010];
inline pair<int, int> get(int *a, int n) {
  int pos = min_element(a, a + n) - a;
  return make_pair(a[pos], pos);
}
int main() {
  int k;
  cin >> k;
  int n1, n2, n3;
  cin >> n1 >> n2 >> n3;
  int t1, t2, t3;
  cin >> t1 >> t2 >> t3;
  for (int i = 0; i < k; ++i) {
    pair<int, int> c1 = get(tm1, n1), c2 = get(tm2, n2), c3 = get(tm3, n3);
    int can = max(c1.first, max(c2.first - t1, c3.first - t1 - t2));
    tm1[c1.second] = can + t1;
    tm2[c2.second] = can + t1 + t2;
    tm3[c3.second] = can + t1 + t2 + t3;
  }
  int ans = 0;
  for (int i = 0; i < n3; ++i) {
    ans = max(ans, tm3[i]);
  }
  cout << ans << endl;
  return 0;
}
