```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[value] will store the length of the longest subsequence ending with 'value'.
    dp = {}
    
    # This will store the maximum length found across all subsequences.
    max_length = 0

    for num in arr:
        # We can form a new subsequence ending with 'num' by extending
        # a previously found subsequence that ends with 'num - 1' or 'num + 1'.
        
        # Get the length of the longest subsequence ending in 'num - 1'.
        # If none exists, its length is 0.
        prev_len = dp.get(num - 1, 0)
        
        # Get the length of the longest subsequence ending in 'num + 1'.
        # If none exists, its length is 0.
        next_len = dp.get(num + 1, 0)
        
        # The length of the new subsequence is 1 (for the current 'num') plus
        # the length of the longest of the two possible preceding subsequences.
        current_length = 1 + max(prev_len, next_len)
        
        # Update the dictionary with the new longest length for a subsequence
        # ending with 'num'.
        dp[num] = current_length
        
        # Keep track of the overall maximum length found so far.
        max_length = max(max_length, current_length)
        
    return max_length

```