fileprivate struct Scanner { private var elements = [String]() private var index = 0 mutating func peek() -> String { while elements.count == index { elements = readLine()!.split(separator: " ").map(String.init) index = 0 } return elements[index] } mutating func next() -> String { let value = peek() index += 1 return value } mutating func nextInt() -> Int { return Int(next())! } mutating func nextDouble() -> Double { return Double(next())! } } fileprivate let MOD = 1000000007 fileprivate struct Zn: Equatable { let n: Int init(_ n: Int) { self.n = n } static func + (lhs: Self, rhs: Self) -> Self { let n = lhs.n + rhs.n return Zn(n < MOD ? n : n - MOD) } static func - (lhs: Self, rhs: Self) -> Self { let n = lhs.n - rhs.n return Zn(n >= 0 ? n : n + MOD) } static func * (lhs: Self, rhs: Self) -> Self { Zn((lhs.n * rhs.n) % MOD) } static func += (lhs: inout Self, rhs: Self) { lhs = lhs + rhs } static func -= (lhs: inout Self, rhs: Self) { lhs = lhs - rhs } static func *= (lhs: inout Self, rhs: Self) { lhs = lhs * rhs } func pow(_ n: Int) -> Self { if n == 0 { return Zn(1) } else if n % 2 == 1 { return self * self.pow(n - 1) } else { return (self * self).pow(n / 2) } } var inverse: Self { self.pow(MOD - 2) } static func == (lhs: Self, rhs: Self) -> Bool { lhs.n == rhs.n } } fileprivate struct Complex: Comparable { let x: Int let y: Int init(_ x: Int, _ y: Int) { self.x = x self.y = y } static func + (lhs: Self, rhs: Self) -> Self { Self(lhs.x + rhs.x, lhs.y + rhs.y) } static func - (lhs: Self, rhs: Self) -> Self { Self(lhs.x - rhs.x, lhs.y - rhs.y) } static func * (lhs: Self, rhs: Self) -> Self { Self(lhs.x * rhs.x - lhs.y * rhs.y, lhs.x * rhs.y + lhs.y * rhs.x) } static func += (lhs: inout Self, rhs: Self) { lhs = lhs + rhs } static func -= (lhs: inout Self, rhs: Self) { lhs = lhs - rhs } static func *= (lhs: inout Self, rhs: Self) { lhs = lhs * rhs } static var zero: Self { Self(0, 0) } var norm: Int { x * x + y * y } var syougen: Int { if x > 0 && y >= 0 { return 0 } else if x <= 0 && y > 0 { return 1 } else if x < 0 && y <= 0 { return 2 } else { return 3 } } var conj: Complex { Complex(x, -y) } static func det(_ lhs: Complex, _ rhs: Complex) -> Int { lhs.x * rhs.y - lhs.y * rhs.x } static func < (lhs: Complex, rhs: Complex) -> Bool { if lhs == rhs { return false } if lhs == .zero { return true } if rhs == .zero { return false } if lhs.syougen != rhs.syougen { return lhs.syougen < rhs.syougen } if Self.det(lhs, rhs) != 0 { return Self.det(lhs, rhs) > 0 } return lhs.norm < rhs.norm } static func == (lhs: Complex, rhs: Complex) -> Bool { lhs.x == rhs.x && lhs.y == rhs.y } func closewise(other: Complex) -> Bool { Self.det(self, other) >= 0 } } fileprivate struct Array2D { let n1: Int let n2: Int private var elements: [Element] init(repeating: Element, _ n1: Int, _ n2: Int) { self.n1 = n1 self.n2 = n2 self.elements = [Element](repeating: repeating, count: n1 * n2) } subscript(i: Int, j: Int) -> Element { get { elements[i * n2 + j] } set { elements[i * n2 + j] = newValue } } } func main() { var scanner = Scanner() let N = scanner.nextInt() var P = [Complex]() for _ in 0 ..< N { let x = scanner.nextInt() let y = scanner.nextInt() P.append(Complex(x, y)) } var answer = 0 for k in 0 ..< N { let O = P[k] let Q = P.filter({ $0 != O }).map({ $0 - O }).sorted() var j = 0 var sum = Complex.zero for i in 0 ..< Q.count { while j < i + Q.count, Q[i].closewise(other: Q[j % Q.count]) { sum += Q[j % Q.count] j += 1 } answer += (Q[i].conj * sum).y answer %= MOD sum -= Q[i] } } answer *= Zn(3).inverse.n answer %= MOD print(answer) } main()