use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  }
}

struct Scanner<R: BufRead> {
  reader: R,
  iter: std::vec::IntoIter<String>
}

#[allow(dead_code)]
impl<R: BufRead> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader: reader, iter: vec![String::new()].into_iter() }
  }
  fn new_line(&mut self) {
    let mut line = String::new();
    self.reader.read_line(&mut line).ok();
    self.iter = line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>().into_iter();
  }
  fn get<T: FromStr>(&mut self) -> T {
    self.iter.next().unwrap().parse().ok().unwrap()
  }
  fn get_as_vec<T: FromStr>(&mut self) -> Vec<T> {
    self.iter.clone().map(|v| v.parse().ok().unwrap()).collect()
  }
  fn get_line(&mut self) -> String {
    let mut line = String::new();
    self.reader.read_line(&mut line).ok();
    line.trim().to_string()
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  let mut ans = 0;
  let mut t = Vec::with_capacity(5);
  for _ in 0..5 {
    sc.new_line();
    t.push(scan!(sc; i32));
  }
  for i in t.iter() {
    if i % 10 == 0 {
      ans += i;
    }
  }
  let mut t = t.iter()
    .filter(|x| *x % 10 != 0)
    .map(|&x| x)
    .collect::<Vec<i32>>();
  t.sort_by(|a, b| (b % 10).cmp(&(a % 10)));
  let mut tmp = 0;
  for v in t.iter() {
    ans += v;
    tmp = 10 - (ans % 10);
    ans += tmp;
  }
  ans -= tmp;
  println!("{}", ans);
}
