(define (read-int n)
  (if (zero? n)
      '()
      (cons (read) (read-int (- n 1)))))

(define (round-ten x)
  (+ x 
     (let ([rem (remainder x 10)])
       (if (zero? rem)
           0
           (- 10 rem)))))

(define (min-rem items)
  (let iter ([s items] [mini 124] [mini-rem 10])
    (if (null? s)
        mini
        (let ([rem (remainder (car s) 10)])
          (if (and (> rem 0) (< rem mini-rem))
              (iter (cdr s) (car s) rem)
              (iter (cdr s) mini mini-rem))))))


(define (solve foods)
  (let ([mini (min-rem foods)]
        [rounded (map round-ten foods)])
    (+ (- (fold + 0 rounded) (round-ten mini)) mini)))
         
  
(let ([foods (read-int 5)])
  (display (solve foods)))
