#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, INF = 1e9 + 7;
long long i, j, k, n, m, s, ans;
long long a[N], d[N], z1[N], z2[N], z3[N];
vector<int> v;
map<int, int> mp;
string s1, s2;
int main() {
  ios_base ::sync_with_stdio(0);
  int n1, n2, n3, t1, t2, t3;
  cin >> n >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  ans = 0;
  i = 0;
  while (n) {
    ans = max(max(z1[i], z2[i] - t1), z3[i] - t2 - t1);
    z1[i + n1] = ans + t1;
    z2[i + n2] = ans + t1 + t2;
    z3[i + n3] = ans + t1 + t2 + t3;
    i++;
    n--;
  }
  cout << ans + t1 + t2 + t3;
}
