from typing import NamedTuple


def compute_score_difference(predictions: NamedTuple) -> float:
    """ Calculates difference in scores from null answer and best answer """
    # assumes that the null answer is always the last prediction
    score_null = predictions[-1].start_logit + predictions[-1].end_logit
    score_non_null = predictions[0].start_logit + predictions[0].end_logit

    return score_null - score_non_null