program abc50
 implicit none
 integer,allocatable::a(:)
 integer(8),parameter::m=10**9+7
 integer(16)::ia,ans=0,ib,N,ic,id
 read(*,*)N
 allocate(a(N))
 read(*,*)(a(ia),ia=1,N)
 do ic=1,N
  a(ic)=mod(a(ic),m)
 end do
 do ib=1,N-1
  ans=ans+a(ib)*(mod(sum(a(ib+1:N)),m))
  ans=mod(ans,m)
 end do
 print'(i0)',ans
end program abc50