I have $n$ red integers $a_1,\ldots,a_n$ (not necessarily distinct), all with $1\leq a_i\leq n$. I also have $n$ blue integers $b_1,\ldots,b_n$ with same constraints. I want to show that there is a (red) subset of the $a_i$'s and a blue subset of the $b_j$'s that add up to the same value. I.e. that there exist two non-empty subsets $I,J\subseteq\{1,\ldots,n\}$ such that $\sum_{i\in I}a_i = \sum_{j\in J}b_j$. This is obvious if $a_1=a_2=\cdots=a_n$ and $b_1=b_2=\cdots=b_n$ and it seems that allowing the $a_i$'s and the $b_j$'s to be distinct only give me more opportunities for the existence of matching subsets but I did not manage to find a proof (or a counter-example?).
At the moment the best I can prove is: if the $a_i$'s and $b_j$'s are all $\leq \frac{n}{2}$ then a solution exists and one can even find a solution where $I,J$ are convex subsets of $\{1,\ldots,n\}$ (i.e., they are subintervals). The solution is found by a greedy algorithm that runs in linear-time.
This looks like a classic problem but I am outside my field ...