def max_sum_nonadjacent(values):
	"""
	This method finds the maximum sum of a sequence of non-adjacent
	numbers in a given sequence. It runs in O(n) time.

	Args:
		values: A iterable sequence of numbers

	Returns:
		The maximum sum of a subsequence of non-adjacent numbers from
		a given sequence.
	"""

	prev_max_incl = 0
	prev_max_excl = 0
    
	for i in values:
		# Between the last two maximums, what is the larger one?
		next_max = max(prev_max_incl, prev_max_excl)
        
		# Include the current value in the sum for comparison on the
		# next iteration
		prev_max_incl = prev_max_excl + i

		# Save the running maximum excluding the current value
		# prevent adjacent sums
		prev_max_excl = next_max

	return max(prev_max_incl, prev_max_excl)