public static int sum(int[] A, int n) { int result = 0; for(int k = 0; k < n; k = k + 1) result = result + A[k]; return result; }