Consider an array $A$ of length $n$ with $A_i \in \{1,\dots,s\}$ for some $s\geq 1$. For example take $s = 6$, $n = 5$ and $A = (2, 5, 6, 3, 1)$. Let us define $g(A)$ as the collection of sums of all the non-empty contiguously indexed subarrays of A. In this case $$g(A) = [2,5,6,3,1,7,11,9,4,13,14,10,16,15,17]$$

In this case all the sums are distinct. However, if we looked at $g((1,2,3,4))$ then the value $3$ occurs twice as a sum and so the sums are not all distinct.

For $s \geq 1$, I would like to understand what the largest $n$ is such that that there exists an array $A$ of length $n$ with all distinct $g(A)$. This question arose orginally as a coding competition and the answers for $s = 1,\dots, 21$ are $n = 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 8, 9, 10, 11, 11, 11, 12, 13, 13, 14, 14$.

On the assumption that an exact formula is hard to come by, is it possible to show its asymptotics? For example, is it true that $n$ is $\Theta(s)$?