function s = r8vec_running_sign3 ( n, v )

%*****************************************************************************80
%
%% r8vec_running_sign3() computes the running threeway sign of an R8VEC.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    21 February 2016
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the number of items.
%
%    real V(N), the data.
%
%  Output:
%
%    integer S(N+1), the running threeway sign.  S(I) is:
%    -1 if the sum of the first I-1 values in V is negative
%     0, if zero
%    +1, if positive.
%
  s = zeros ( n + 1, 1 );
%
%  Sum.
%
  for i = 2 : n + 1
    s(i) = s(i-1) + v(i-1);
  end

  s(1:n+1) = s(1:n+1) ./ max ( abs ( s(1:n+1) ), 1.0 );

  return
end
