#include <bits/stdc++.h>
using namespace std;
const int MaxN = 30010000;
short int a1[MaxN], a2[MaxN], a3[MaxN];
int k, n1, n2, n3, t1, t2, t3;
int main() {
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  for (int i = 0; i <= 30000000; ++i) {
    if (i) {
      a1[i] += a1[i - 1];
      a2[i] += a2[i - 1];
      a3[i] += a3[i - 1];
    }
    while (a1[i] < n1 && a2[i] < n2 && a3[i] < n3) {
      if (!--k) {
        cout << i + t1 + t2 + t3 << endl;
        return 0;
      }
      ++a1[i];
      --a1[i + t1];
      ++a2[i];
      --a2[i + t2];
      ++a3[i];
      --a3[i + t3];
    }
  }
  return 0;
}
