var array1: [Int] = []
var array2 : [Int] = []

for _ in 0..<5 {
  let line = readLine()!
  let item = Int(line)!
  if item % 10 == 0 {
    array1.append(item)
  } else {
    array2.append(item)
  }
}

array2.sortInPlace { (lhs, rhs) in
  let a = lhs % 10
  let b = rhs % 10
  return a > b
}

var sum = 0
for i in 0..<array1.count {
  let item = array1[i]
  sum += item
}

for i in 0..<array2.count-1 {
  let item = array2[i]
  let amari = item % 10
  let add = item + 10 - amari
  sum += add
}
sum += array2[array2.count]

print(sum)
