#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
const long long linf = 1e18 + 5;
const int N = 1000 + 5;
int k, n1, n2, n3, t1, t2, t3, a1[N], a2[N], a3[N], mx;
int main() {
  ios ::sync_with_stdio(0);
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  for (int i = 1; i <= k; i++) {
    int i1 = min_element(a1 + 1, a1 + n1 + 1) - a1;
    int i2 = min_element(a2 + 1, a2 + n2 + 1) - a2;
    int i3 = min_element(a3 + 1, a3 + n3 + 1) - a3;
    mx = max(a1[i1] + t1 + t2 + t3, max(a2[i2] + t2 + t3, a3[i3] + t3));
    a1[i1] = mx - t3 - t2;
    a2[i2] = mx - t3;
    a3[i3] = mx;
  }
  cout << mx << '\n';
  return 0;
}
