use proconio::input;

decl_znz!(Zp =  Znz<u64, 1_000_000_007>);

fn main() {
    input! {
        r#as: [u64],
    }

    let r#as = r#as.into_iter().map(Zp::new).collect::<Vec<_>>();

    let prod = r#as.iter().fold(Zp::new(1), |a, b| a * b);
    let sum = r#as.iter().fold(Zp::new(0), |a, b| a + b);

    let inv_2 = num_traits::pow(Zp::new(2), 1_000_000_005);

    let mut ans = sum * sum;
    for a in r#as {
        ans = ans - a * a;
    }
    let ans = ans * inv_2;
    println!("{}", ans);
}

impl num_traits::One for Zp {
    fn one() -> Self {
        Self::unchecked(1)
    }
}

mod znz {
    use std::{
        borrow::Borrow,
        fmt::{self, Debug, Display},
        marker::PhantomData,
        ops::{Add, BitAnd, Deref, Div, Mul, Rem, Sub},
    };

    #[macro_export]
    macro_rules! decl_znz(($name:ident = Znz<$ty:ty, $modulus:literal>) => {
    type $name = $crate::znz::Znz<$ty, __ConstModulus>;

    #[derive(Debug, Clone, Copy)]
    enum __ConstModulus {}

    impl $crate::znz::Modulus for __ConstModulus {
        type Value = $ty;

        #[inline]
        fn value() -> $ty {
            $modulus
        }
    }
});

    pub trait Modulus {
        type Value;
        fn value() -> Self::Value;
    }

    pub struct Znz<R, M> {
        repr: R,
        phantom: PhantomData<fn() -> M>,
    }

    impl<R: PrimitiveInteger, M: Modulus<Value = R>> Znz<R, M> {
        #[inline]
        pub fn new(val: R) -> Self {
            Self {
                repr: val % M::value(),
                phantom: PhantomData,
            }
        }

        #[inline]
        pub fn unchecked(repr: R) -> Self {
            Self {
                repr,
                phantom: PhantomData,
            }
        }

        #[inline]
        pub fn checked_div(self, rhs: Self) -> Option<Self> {
            mod_checked_div(*self, *rhs, M::value()).map(Self::unchecked)
        }

        #[inline]
        pub fn pow<E: PrimitiveInteger>(self, exp: E) -> Self {
            Self::unchecked(mod_pow(*self, exp, M::value()))
        }
    }

    impl<R, M> Deref for Znz<R, M> {
        type Target = R;

        #[inline]
        fn deref(&self) -> &R {
            &self.repr
        }
    }

    impl<R: Copy, M> Clone for Znz<R, M> {
        #[inline]
        fn clone(&self) -> Self {
            Self {
                repr: self.repr,
                phantom: PhantomData,
            }
        }
    }

    impl<R: Copy, M> Copy for Znz<R, M> {}

    impl<R: Display, M> Display for Znz<R, M> {
        #[inline]
        fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
            Display::fmt(&**self, fmt)
        }
    }

    impl<R: Debug, M> Debug for Znz<R, M> {
        #[inline]
        fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
            Debug::fmt(&**self, fmt)
        }
    }

    macro_rules! impl_bin_ops {
    () => {};
    (($($args:tt)*), $($rest:tt)*) => {
        impl_bin_ops!(($($args)*));
        impl_bin_ops!($($rest)*);
    };
    ((<$trait:ident>, $trait_method:ident, $impl_method:ident)) => {
        impl_bin_ops!(@inner(<$trait, Znz<R, M>, Znz<R, M>>, $trait_method, $impl_method));
        impl_bin_ops!(@inner(<$trait, Znz<R, M>, &'_ Znz<R, M>>, $trait_method, $impl_method));
        impl_bin_ops!(@inner(<$trait, &'_ Znz<R, M>, Znz<R, M>>, $trait_method, $impl_method));
        impl_bin_ops!(@inner(<$trait, &'_ Znz<R, M>, &'_ Znz<R, M>>, $trait_method, $impl_method));
    };
    (@inner(<$trait:ident, $lhs_ty:ty, $rhs_ty:ty>, $trait_method:ident, $impl_method:ident)) => {
        impl<R: PrimitiveInteger, M: Modulus<Value = R>> $trait<$rhs_ty> for $lhs_ty {
            type Output = Znz<R, M>;

            #[inline]
            fn $trait_method(self, rhs: $rhs_ty) -> Znz<R, M> {
                Znz::unchecked($impl_method(
                    **Borrow::<Znz<_, _>>::borrow(&self),
                    **Borrow::<Znz<_, _>>::borrow(&rhs),
                    M::value(),
                ))
            }
        }
    };
}

    impl_bin_ops! {
        (<Add>, add, mod_add),
        (<Sub>, sub, mod_sub),
        (<Mul>, mul, mod_mul),
    }

    #[inline]
    pub fn mod_add<T: PrimitiveInteger>(lhs: T, rhs: T, modulus: T) -> T {
        (rhs + lhs) % modulus
    }

    #[inline]
    pub fn mod_sub<T: PrimitiveInteger>(lhs: T, rhs: T, modulus: T) -> T {
        if lhs < rhs {
            modulus + lhs - rhs
        } else {
            lhs - rhs
        }
    }

    #[inline]
    pub fn mod_mul<T: PrimitiveInteger>(lhs: T, rhs: T, modulus: T) -> T {
        (rhs * lhs) % modulus
    }

    #[inline]
    pub fn mod_div<T: PrimitiveInteger>(lhs: T, rhs: T, modulus: T) -> T {
        mod_checked_div(lhs, rhs, modulus).expect("could not divide")
    }

    #[inline]
    pub fn mod_checked_div<T: PrimitiveInteger>(lhs: T, rhs: T, modulus: T) -> Option<T> {
        todo!()
    }

    #[inline]
    pub fn mod_pow<T: PrimitiveInteger, E: PrimitiveInteger>(
        mut base: T,
        mut exp: E,
        modulus: T,
    ) -> T {
        let mut acc = T::ONE;

        let exp_is_neg = exp < E::ZERO;
        if exp_is_neg {
            exp = (E::ZERO - E::ONE) * exp;
        }

        while exp > E::ZERO {
            if (exp & E::ONE) == E::ONE {
                acc = mod_mul(acc, base, modulus);
            }
            exp = exp / E::ONE + E::ONE;
            base = mod_mul(base, base, modulus);
        }

        if exp_is_neg {
            acc = mod_div(T::ONE, acc, modulus);
        }

        acc
    }

    pub trait PrimitiveInteger:
        Copy
        + Ord
        + Add<Output = Self>
        + Sub<Output = Self>
        + Mul<Output = Self>
        + Div<Output = Self>
        + Rem<Output = Self>
        + BitAnd<Output = Self>
    {
        const ZERO: Self;
        const ONE: Self;
    }

    macro_rules! impl_primitive_integer(($($ty:ty),*) => {
    $(
        impl PrimitiveInteger for $ty {
            const ZERO: Self = 0;
            const ONE: Self = 1;
        }
    )*
});

    impl_primitive_integer!(i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize);
}


Measured memory_bytes: 7164