The $N(n)$ is exponential in $n$. First, I present a lower bound. The construction is recursive. Call a sequence whose first differences are monotone, $1$-monotone. Suppose $\mathbf{a}=a_1,\dotsc,a_M$ is a sequence that contains no $1$-monotone $N$-term subsequence. Pick an number $R$ that is larger than $\max_{i,j}(a_i-a_j)$. Then the sequence $\mathbf{b}=a_1,\dotsc,a_M,a_1+R,\dotsc,a_M+R$ contains no $1$-monotone subsequence of length $N+1$. Indeed, the subsequence cannot contain $N$ elements from the same half of $\mathbf{b}$. Hence, it must contain at least $2$ elements from each of the halves, which is impossible by the choice of $R$.
The upper bound is also recursive. Suppose we are given a sequence $\mathbf{a}$. We may assume that it is monotone (by losing only a square). Then write $\mathbf{a}$ as a concatenation of two sequences $\mathbf{b}$ and $\mathbf{c}$. By induction we can find $1$-monotone subsequences $\mathbf{b}'$ and $\mathbf{c}'$ in $\mathbf{b}$ and $\mathbf{c}$ respectively. Then the concatenation of the last element of $\mathbf{c}$ with $\mathbf{b}'$, or the first element of $\mathbf{b}$ with $\mathbf{c}'$ is a desired subsequence.