```python
def cal_sum(n):
    """
    Calculates the sum of the first n Perrin numbers.
    P(0) = 3, P(1) = 0, P(2) = 2
    P(n) = P(n-2) + P(n-3) for n > 2
    """
    if n <= 0:
        return 0

    # Initialize the first three Perrin numbers
    p0, p1, p2 = 3, 0, 2

    if n == 1:
        return p0
    if n == 2:
        return p0 + p1
    
    # Initialize the sum with the first three numbers for n >= 3
    total_sum = p0 + p1 + p2
    
    # Loop to calculate subsequent numbers and add to the sum
    for _ in range(3, n):
        p_next = p0 + p1
        total_sum += p_next
        # Update the sequence for the next iteration
        p0, p1, p2 = p1, p2, p_next
        
    return total_sum

```