#include using namespace std; #define int long long #define double long double #define ii pair #define app push_back #define all(a) a.begin(), a.end() #define bp __builtin_popcount #define ll long long const int N = 2007, C = 1e4 + 7, MOD = 1000 * 1000 * 1000 + 7; int mod(int n) { n %= MOD; if (n < 0) return n + MOD; else return n; } int fp(int a, int p) { int ans = 1, c = a; for (int i = 0; (1ll << i) <= p; ++i) { if ((p >> i) & 1) ans = mod(ans * c); c = mod(c * c); } return ans; } int dv(int a, int b) { return mod(a * fp(b, MOD - 2)); } int n, ans = 0; struct Point { int x, y; bool operator < (Point p) { return (y < p.y) || (y == p.y && x > p.x); } } a[N]; int cp(int x1, int y1, int x2, int y2) { return x1 * y2 - y1 * x2; } struct Line { int x, y, i, j; bool operator < (Line l) { int t = cp(x, y, l.x, l.y); return t > 0 || (t == 0 && i < l.i) || (t == 0 && i == l.i && j < l.j); } }; struct Fen { int f[N]; void clear() { for (int i = 0; i < N; ++i) f[i] = 0; } void add(int i, int x) { for (; i < N; i |= i + 1) f[i] += x; } int get(int i) { int ans = 0; for (; i >= 0; i &= i + 1, --i) ans += f[i]; return ans; } int get(int l, int r) { return get(r) - get(l - 1); } } fx, fy; int pos[N]; Point ord[N]; signed main() { #ifdef HOME freopen("input.txt", "r", stdin); #else ios_base::sync_with_stdio(0); cin.tie(0); #endif cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i].x >> a[i].y; a[i].x += C; a[i].y += C; } sort(a, a + n); #define mp make_pair for (int i = 0; i + 1 < n; ++i) assert(mp(a[i].x,a[i].y)!=mp(a[i+1].x,a[i+1].y)); for (int i = 0; i < n; ++i) ord[i] = a[i]; vector l; for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { l.app({a[j].x - a[i].x, a[j].y - a[i].y, i, j}); } } for (int i = 0; i < n; ++i) pos[i] = i; sort(all(l)); int ptr = 0; for (int i = 0; i < n; ++i) { fx.add(i, a[i].x); fy.add(i, a[i].y); } auto add = [&] (int &a, int b) { a = mod(a + b); }; while (ptr < l.size()) { int t = ptr; while (ptr < l.size() && cp(l[t].x, l[t].y, l[ptr].x, l[ptr].y) == 0) { auto &e = l[ptr]; swap(pos[e.i], pos[e.j]); fx.add(pos[e.i], ord[pos[e.j]].x-ord[pos[e.i]].x); fy.add(pos[e.i], ord[pos[e.j]].y-ord[pos[e.i]].y); fx.add(pos[e.j], ord[pos[e.i]].x-ord[pos[e.j]].x); fy.add(pos[e.j], ord[pos[e.i]].y-ord[pos[e.j]].y); swap(ord[pos[e.i]], ord[pos[e.j]]); int j = e.i, k = e.j; int C = a[j].x * a[k].y - a[j].y * a[k].x; int A = (a[j].y - a[k].y); int B = (a[k].x - a[j].x); //cout << A << ' ' << B << ' ' << C << endl; if (n <= 500) { for (int i = 0; i + 1 < n; ++i) assert(ord[i].x * A + ord[i].y * B <= ord[i+1].x * A + ord[i+1].y * B); } int l = -1, r = n; while (l < r - 1) { int m = (l + r) >> 1; if (C + ord[m].x * A + ord[m].y * B < 0) l = m; else r = m; } int lx = fx.get(l); int ly = fy.get(l); A = mod(A); B = mod(B); C = mod(C); add(ans, -C * (l + 1)); add(ans, -A * lx); add(ans, -B * ly); add(ans, C * (n - l - 1)); add(ans, A * (fx.get(n) - lx)); add(ans, B * (fy.get(n) - ly)); ++ptr; } } cout << dv(ans, 3) << '\n'; }