#!/usr/bin/perl -w

use v5.30;
use strict;

my %seen;
my $freq = 0;
chomp(my @changes = <>);
while (1) {
	for my $x (@changes) {
		$freq += $x;
		if ($seen{$freq}++) {
			say $freq;
			exit 0;
		}
	}
}



