def count_trajectories(n: int) -> int:
    """
    The Grasshopper is in position 1.
    The Grasshopper may jump to +1, +2 or +3.
    How many possible trajectories does the grasshopper have to get to position n?
    If n<=1, consider that the Grasshopper has 0 possible trajectory.

    >>> count_trajectories(0)
    0
    >>> count_trajectories(1)
    0
    >>> count_trajectories(2)
    1
    >>> count_trajectories(3)
    2
    >>> count_trajectories(4)
    3
    >>> count_trajectories(7)
    20
    >>> count_trajectories(-3)
    0
    """
    if n <= 1:
        return 0

    trajectories = [0, 0, 1, 2, 3] + [0] * (n - 4)

    for i in range(5, n + 1):
        trajectories[i] = trajectories[i - 1] + trajectories[i - 2] + trajectories[i - 3]

    return trajectories[n]