import Foundation

func readInt() -> Int {
    Int(readLine()!)!
}

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func tuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func tuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func tuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
    
    func safe(at index: Index) -> Element? {
        self.indices.contains(index) ? self[index] : nil
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating _read {
            if let note = dictionary[argument] {
                yield note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                yield result
            }
        }
    }
}

extension Dictionary {
    init(_ initialize: (inout Self) -> ()) {
        var dictionary = Self()
        initialize(&dictionary)
        self = dictionary
    }
}

extension Int {
    var abs: Int {
        self < .zero ? -self : self
    }
}

@propertyWrapper
struct Mod {
    
    let base: Int
    var value: Int
    
    static let defaultBaseNumber = 1_000_000_007
    
    init(_ value: Int, base: Int = defaultBaseNumber) {
        self.base = base
        self.value = value % base
        if value < 0 { self.value += base }
    }
    
    init(wrappedValue: Int, base: Int = defaultBaseNumber) {
        self = .init(wrappedValue, base: base)
    }
    
    var wrappedValue: Int {
        get { return value }
        set {
            value = newValue % base
            if value < 0 { value += base }
        }
    }
    
    var projectedValue: Int { base }
}

extension Mod: ExpressibleByIntegerLiteral {
    init(integerLiteral value: Int) {
        self = .init(value)
    }
}

extension Mod: AdditiveArithmetic {
    private static func operate(_ f: @escaping (Int, Int) -> Int) -> (Mod, Mod) -> Mod {
        return { lhs, rhs in
            assert(lhs.base == rhs.base, "Base should be same number.")
            let num = f(lhs.value, rhs.value)
            return Mod(num, base: lhs.base)
        }
    }
    
    static func + (lhs: Mod, rhs: Mod) -> Mod { operate(+)(lhs, rhs) }
    static func - (lhs: Mod, rhs: Mod) -> Mod { operate(-)(lhs, rhs) }
    static func * (lhs: Mod, rhs: Mod) -> Mod { operate(*)(lhs, rhs) }
    static func *= (lhs: inout Mod, rhs: Mod) { lhs = lhs * rhs }
}

extension Mod: Numeric {
    init?<T>(exactly source: T) where T : BinaryInteger {
        guard let int = Int(exactly: source) else { return nil }
        self = Mod(int)
    }
    
    var magnitude: Int { value }
}


extension Mod: CustomStringConvertible {
    var description: String {
        let _ = base.signum()
        let string = String(format: "%\(9)d", value)
        return "Mod(\(string), base: \(base))"
    }
}

// MARK: ---------------------------------------------------------------------

// import Foundation

func problem_c(_ an: [Mod]) -> Int {
    var res = Mod(0)
    var sum = an.reduce(0, +)
    for i in an {
        sum -= i
        res += i * sum
    }
    return res.value
}

func heavy_problem_c(_ an: [Mod]) -> Int {
    var res = Mod(0)
    for i in an.indices {
        let under = an[i]
        for j in 0..<i {
            let upper = an[j]
            //        print(under.value, "*", upper.value, "=", (under * upper).value)
            res += under * upper
        }
    }
    return res.value
}

func main() {
    let _ = readLine()
    let an = readInts().map(Mod.init)
    print(problem_c(an))
}

func test(_ n: Int = 10) {
    for _ in 0..<n {
        let an = (0..<10)
            .map { _ in Int.random(in: 0...1_000_000_007) }
            .map(Mod.init)
        print(an.map(\.value))
        let ans = problem_c(an)
        let hev = heavy_problem_c(an)
        if ans == hev {
            print("success", ans)
        } else {
            print("FAILED  - Heavy:  \(hev)")
            print("        - Answer: \(ans)")
        }
    }
}

main()


Measured memory_bytes: 26376