>When no more interesting kata can be resolved, I just choose to create the new kata, to solve their own, to enjoy the process  --myjinxin2015 said

# Description:

```if:javascript
Given an array `arr` that contains some integers(positive, negative or 0), and a `range` list such as `[[start1,end1],[start2,end2],...]`, start and end are the index of `arr` and start always less than end. Your task is to calculate the sum value of each range (start index and end index are both inclusive), and return the maximum sum value.
```
```if:ruby
Given an array (`arr`) of integers and an array (`ranges`) of ranges (e.g. `[[1, 32], [16, 24],...]`), which represent an index range of `arr`, calculate the sum of each range (start index and end index are both inclusive) of `arr`, and return the maximum sum.
```
```if:php
Given an array `$a` that contains some integers and a `$range` list such as `[[$start1, $end1], [$start2, $end2], ... ]` where `$start(n)` and `$end(n)` are valid keys of the non-associative array `$a` and `$start(n)` is always guaranteed to be strictly less than `$end(n)`.  Your task is to calculate the sum value of each range (start index and end index are both inclusive) and return the maximum sum value.
```
```if:haskell
Given a list `arr` that contains some integers(positive, negative or 0), and a `range` list such as `[(start1,end1),(start2,end2),...]`, start and end are the index of `arr` and start always less than end. Your task is to calculate the sum value of each range (start index and end index are both inclusive), and return the maximum sum value.
```

For example:
 
# Note:

 - `arr`/`$a` always has at least 5 elements;
 - `range`/`$range`/`ranges` always has at least 1 element;
 - All inputs are valid;
 - This is a simple version, if you want some challenge, please [try the challenge version](https://www.codewars.com/kata/the-maximum-sum-value-of-ranges-challenge-version/).

# Some Examples

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def max_sum(arr,ranges):
	

Solutions:
def max_sum(arr, ranges):
	return max((sum(arr[start:stop + 1]) for (start, stop) in ranges))


from itertools import accumulate

def max_sum(arr, ranges):
	xs = list(accumulate(arr)) + [0]
	return max((xs[j] - xs[i - 1] for (i, j) in ranges))


def max_sum(arr, ranges):
	return max((sum(arr[start:end + 1]) for (start, end) in ranges))


def max_sum(lst, ranges):
	return max((sum(lst[i:j + 1]) for (i, j) in ranges))


def max_sum(arr, ranges):
	return max((sum(arr[a:b + 1]) for (a, b) in ranges))


def max_sum(arr, ranges):
	x = [sum([arr[i] for i in range(R[0], R[1] + 1)]) for R in ranges]
	return max(x)


def max_sum(arr, ranges):
	return max((sum(arr[p[0]:p[1] + 1]) for p in ranges)) if ranges else 0


def max_sum(arr, ranges):
	results = []
	for r in ranges:
		partialSum = 0
		for j in range(r[0], r[1] + 1):
			partialSum += arr[j]
		results.append(partialSum)
	return max(results)


def max_sum(arr, ranges):
	return max([sum([arr[b] for b in range(i[0], i[1] + 1)]) for i in ranges])


def max_sum(arr, ranges):
	st = []
	for i in ranges:
		p = 0
		for j in range(i[0], i[1] + 1):
			p += arr[j]
		st.append(p)
	return max(st)