cumulative sums
This function should do:
f = x \[Function] Last[Intersection[x, Accumulate[x]]]
(Note that Intersection
automatically orders lists, so we merely have to take the last element of the intersection.)
Testing:
lists = {{8, 2, 3, 9, 22},
{9, 11, 21, 3, 44, 12, 3},
{3, 8, 2, 1, 12, 26},
{8, 4, 6, 2, 9, 11, 40, 3},
{3, 7, 10, 2, 14, 36, 4}
};
f /@ lists
{22, 44, 26, 40, 36}
Edit
kglr pointed out that the equality of position might be necessary for a match. In this case, the following function might be what you are looking for.
g = x \[Function] Max[Pick[Rest[x], Unitize[Accumulate[Most[x]] - Rest[x]], 0]]
We obtain
g /@ lists
{22, 44, 26, 40, 36}
and with kglr's lists2
lists2 = {{22, 2, 9, 8, 3},
{9, 3, 12, 44, 3, 21, 11},
{12, 8, 2, 3, 1, 26},
{2, 11, 6, 8, 4, 9, 3, 40},
{3, 10, 4, 7, 14, 36, 2}
};
g /@ lists2
{-∞, 12, 26, -∞, -∞}
(And yes, the supremum of an empty set is $-\infty$.)
Another approach is to recognize that what you want is the max value in each list. Hence:
lists = {{8, 2, 3, 9, 22},
{9, 11, 21, 3, 44, 12, 3},
{3, 8, 2, 1, 12, 26},
{8, 4, 6, 2, 9, 11, 40, 3},
{3, 7, 10, 2, 14, 36, 4}};
Max @@@ lists
{22, 44, 26, 40, 36}
f1 = Module[{i = Length@#, a = #, b = Accumulate @ #},
While[a[[i]] - b[[--i]] != 0 && i > 0]; ; If[i == 0, {}, a[[i + 1]]]] &;
f2 = Module[{a = Reverse @ Accumulate @ Most @ #, b = Reverse @ Rest @ #, l},
l = LengthWhile[a - b, # != 0 &]; If[l == Length@a, {}, a[[1 + l]]]] &;
Examples:
lists = {{8, 2, 3, 9, 22},
{9, 11, 21, 3, 44, 12, 3},
{3, 8, 2, 1, 12, 26},
{8, 4, 6, 2, 9, 11, 40, 3},
{3, 7, 10, 2, 14, 36, 4}};
{f1 /@ lists, f2 /@ lists}
{{22, 44, 26, 40, 36}, {22, 44, 26, 40, 36}}
SeedRandom[1]
lists2 = RandomSample/@lists
{{22, 2, 9, 8, 3},
{9, 3, 12, 44, 3, 21, 11},
{12, 8, 2, 3, 1, 26},
{2, 11, 6, 8, 4, 9, 3, 40},
{3, 10, 4, 7, 14, 36, 2}}
{f1 /@ lists2, f2 /@ lists2}
{{{}, 12, 26, {}, {}}, {{}, 12, 26, {}, {}}}