• + 0 comments

    Best I can come up with at 3 am.
    (Python3)

    from functools import reduce
    
    MOD = 1_000_000_007
    
    def _value_of_S_reduce(x:int,y:int)->int:
        return (x+y+x*y) % MOD
    
    def value_of_S(l:list)->int:
        return reduce(_value_of_S_reduce,l)
        
    if __name__=='__main__':
        _ = input()
        print(value_of_S(list(map(int,input().split()))))