def sum2(arr, NaN=False):
    """Return the sum of an array.
    If NaN==True, NaNs are ingnored and return the sum of the other elements"""
    
    if NaN:
        s=0
        for a in arr:
            if a==a:
                s+=a
    else:
        s=sum(arr)
    
    return s