#!/usr/bin/perl -w

use v5.36;
use strict;
use experimental 'multidimensional';
use List::Util qw(sum);

local $/  = "\n\n";

chomp (my @elves = <>);
my @l;

for my $elf (@elves) {
	my $s = sum split(/\n/, $elf);
	push @l, $s;
}

@l = sort { $b <=> $a } @l;
say sum splice (@l, 0, 3);

