#include <bits/stdc++.h>
using namespace std;
template <typename t1, typename t2>
ostream& operator<<(ostream& os, const pair<t1, t2>& a) {
  os << a.first << ' ' << a.second;
  return os;
}
template <typename typ>
void vout(vector<typ>& v) {
  for (int vint = 0; vint < (int)(v).size(); vint++) {
    cout << (v)[vint];
    if (vint == (int)(v).size() - 1)
      cout << '\n';
    else
      cout << ' ';
  }
}
template <typename typ>
void arrout(typ* arr, int l) {
  for (int i = 0; i < l; i++) {
    cout << arr[i];
    if (i < l - 1)
      cout << ' ';
    else
      cout << '\n';
  }
}
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
int main() {
  std::ios_base::sync_with_stdio(false);
  int k, n1, n2, n3, t1, t2, t3;
  cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
  queue<int> wash, dry, fold;
  int toWash = 0, toDry = 0, toFold = 0;
  toWash = k;
  int t = 0;
  int xt1, xt2, xt3;
  while (true) {
    while (toWash > 0 && (int)(wash).size() < n1) {
      wash.push(t);
      toWash--;
    }
    while (toDry > 0 && (int)(dry).size() < n2) {
      dry.push(t);
      toDry--;
    }
    while (toFold > 0 && (int)(fold).size() < n3) {
      fold.push(t);
      toFold--;
    }
    if ((int)(wash).size() == 0 && (int)(dry).size() == 0 &&
        (int)(fold).size() == 0) {
      break;
    }
    xt1 = xt2 = xt3 = (1 << 30);
    if ((int)(wash).size() > 0) {
      xt1 = wash.front() + t1;
    }
    if ((int)(dry).size() > 0) {
      xt2 = dry.front() + t2;
    }
    if ((int)(fold).size() > 0) {
      xt3 = fold.front() + t3;
    }
    if (xt1 <= xt2 && xt1 <= xt3) {
      t = xt1;
      wash.pop();
      toDry++;
    } else if (xt2 <= xt1 && xt2 <= xt3) {
      t = xt2;
      dry.pop();
      toFold++;
    } else {
      t = xt3;
      fold.pop();
    }
  }
  cout << (t) << '\n';
}
