#include <bits/stdc++.h>
using namespace std;
int piecescount, washcount, drycount, foldcount, washtime, drytime, fouldtime;
int res;
deque<int> wash, dry, fold;
void push(deque<int>& wash, int& washcount) {
  for (int i = 0; i < washcount; ++i) wash.push_back(0);
}
int main() {
  cin >> piecescount >> washcount >> drycount >> foldcount >> washtime >>
      drytime >> fouldtime;
  push(wash, washcount);
  push(dry, drycount);
  push(fold, foldcount);
  for (int i = 0; i < piecescount; ++i) {
    int t1 = wash.front();
    int t2 = dry.front();
    int t3 = fold.front();
    int newtime = max({t1, t2 - washtime, t3 - washtime - drytime});
    wash.pop_front();
    dry.pop_front();
    fold.pop_front();
    wash.push_back(washtime + newtime);
    dry.push_back(newtime + drytime + washtime);
    fold.push_back(newtime + drytime + washtime + fouldtime);
    res = newtime + drytime + washtime + fouldtime;
  }
  cout << res;
}
