import Foundation

class City {
    
    private let delay: Int
    private let initial: Int
    private let output: Int
    private let prev: City?
    
    init(delay: Int, initial: Int, output: Int, prev: City?) {
        self.delay = delay
        self.initial = initial
        self.output = output
        self.prev = prev
    }
    
    func outputPerMin() -> Int {
        if let prev = prev {
            return min(prev.outputPerMin(), output)
        } else {
            return output
        }
    }
    
    func outputTimes() -> Int {
        var sum = initial
        if let prev = prev {
            sum += prev.outputPerMin() * prev.outputTimes()
        }
        let output = outputPerMin()
        return Int(ceil(Double(sum) / Double(output)))
    }
    
    func totalTime() -> Int {
        return delay + outputTimes()
    }
}

let N = Int(readLine()!)!

var cities: [City] = []
var prev: City?
for i in 0 ..< 5 {
    let output = Int(readLine()!)!
    let city = City(
        delay: i,
        initial: i == 0 ? N : 0,
        output: output,
        prev: prev)
    cities.append(city)
    prev = city
}

let answer = cities.last!.totalTime()

print(answer)
