public long process() {
        for (int i = 0; i < _n; i++) {
            _left[i] = 1;
            _right[i] = 1;
        }

        for (int i = 1; i < _n; i++) {
            if (_rating[i] > _rating[i - 1])
                _left[i] = _left[i - 1] + 1;
        }
        for (int i = _n - 2; i >= 0; i--) {
            if (_rating[i] > _rating[i + 1])
                _right[i] = _right[i + 1] + 1;
        }

        long sum = 0;
        for (int i = 0; i < _n; i++)
            sum += Math.max(_left[i], _right[i]);
        return sum;

    }