def non_adjacent_max_sum(putlen=input(), putnum=input()): lookup_lane = [] for sn in putnum.split(' '): sn = int(sn) lookup_lane.append(sn) previous_sum_non_adjacent = 0 previous_sum_adjacent = 0 for idx, lookup in enumerate(lookup_lane): lookup_included_sum = lookup + previous_sum_non_adjacent lookup_excluded_sum = max(previous_sum_adjacent, previous_sum_non_adjacent) previous_sum_non_adjacent = lookup_excluded_sum previous_sum_adjacent = lookup_included_sum return max(lookup_excluded_sum, lookup_included_sum) print(non_adjacent_max_sum())