use strict; use warnings; my $N = <>; my $line = <>; # my $N = 2; # my $line = "77144313318378908 540010193228652352"; chomp( $N, $line ); my @num = split / /,$line; if ($N == (scalar @num) ){ my $sum = sum(@num); print "$sum\n"; }else{ die "maybe split error" }; sub sum { my @array = @_; my $sum = 0; for my $num (@array){ $sum += $num; } return $sum; }