Program-2

Given an array A of N positive integers, you are provided with two functions sumprefix(i) and sumsuffix(i).
The sumprefix(i) function computes the sum of first i numbers of the array.
The sumsuffix(i) function computes the sum of last N - i + 1 numbers of the array.
Your task is to find the minimum index i for which the value sumprefix(i) + sumsuffix(i) is the minimum. Which means you need to minimize the value of sumprefix(i) + sumsuffix(i) and find the least index i for which this value is attained.
INPUT:
The first line of input contains the integer N denoting the number of elements in array A.
The second line contains the N separated elements of array A.
OUTPUT:
Output the single line containing the answer.
SAMPLE INPUT1:
5
2 3 1 4 5
SAMPLE OUTPUT1:
2
SAMPLE INPUT1:
9
5 7 3 11 4 6 8 2 9
SAMPLE OUTPUT1:
7

No comments:

Post a Comment