You can't use binary search here, since you need to check every [start, end] combindation. Also, if you search in both directions with binary search, it is not binary search anyway.
I'd suggest the following solution:
// Remove this, if you want all matches
bool found = false;
for (int start = 0; start < a.count; start++)
{
// Maybe you need end = start + 1, not sure
for (int end = start; end < a.count; end++)
{
if (AreSumsEqual(start, end)
{
// Found! Let's break to avoid useless iterations,
// if we only want one match.
found = true;
break;
}
}
if (found)
{
break;
}
}
This runs in O([n(n - 1)] / 2) (if I'm not mistaken) which is O(n²) in the worst case. Since you have to check all all [start, end] combinations, you can't solve this with a smaller order of magnitude.
EDIT: This is provided I understood your question.