#!/usr/bin/env perl
use strict;
use warnings;

my @adapters;
while (<ARGV>) {
    chomp;
    push(@adapters, $_);
}

@adapters = sort { $a <=> $b } @adapters;

my %spread;
my $last = 0;
for my $n (@adapters) {
    my $delta = $n - $last;
    if ($delta > 3) {
        die "assert -- greater than 3 diff\n";
    }
    $spread{$delta}++;
    $last = $n;
}

$spread{3}++; # for the device

my $result = $spread{1} * $spread{3};
print "$result\n";
