```python
def longest_subseq_with_diff_one(arr, n):
    """
    Finds the length of the longest subsequence such that the
    difference between adjacent elements is one.
    """
    # dp[x] will store the length of the longest subsequence ending with x
    dp = {}
    
    # To store the maximum length of the subsequence found so far
    max_length = 0
    
    # Iterate through each element of the array
    for x in arr:
        # The length of the subsequence ending with x is 1 plus the
        # maximum length of a subsequence ending with x-1 or x+1.
        # We look up these lengths from our dp map.
        # If a predecessor is not in the map, its length is 0.
        current_length = 1 + max(dp.get(x - 1, 0), dp.get(x + 1, 0))
        
        # Store the calculated length for the current number x.
        # This updates the longest subsequence found so far that ends with x.
        dp[x] = current_length
        
        # Update the overall maximum length found.
        max_length = max(max_length, current_length)
            
    return max_length

```