#include<bits/stdc++.h>
#define LLI long long int

using namespace std;

LLI area(LLI x1, LLI y1, LLI x2, LLI y2, LLI x3, LLI y3)
{
    return abs((x1*(y2-y3) + x2*(y3-y1)+ x3*(y1-y2)));
}
bool isInside(LLI x1, LLI y1, LLI x2, LLI y2, LLI x3, LLI y3, LLI x, LLI y)
{
    float A = area (x1, y1, x2, y2, x3, y3);
    float A1 = area (x, y, x2, y2, x3, y3);
    float A2 = area (x1, y1, x, y, x3, y3);
    float A3 = area (x1, y1, x2, y2, x, y);
    return (A == A1 + A2 + A3);
}
const int mod = 1e9+7;


LLI cal_pow(LLI x){
    LLI res;
    if (x == 0) res=1;
    else if (x == 1)    res=2;
    else {
        res = cal_pow(x/2);
        if (x % 2 == 0)
            res = (res * res) % mod;
        else
            res = (((res*res) % mod) * 2) % mod;
    }
    return res;
}
int main() {
    LLI n, empt;
    scanf("%lld", &n);
    if(n == 3) {
        LLI a1, a2, b1, b2, c1, c2, rez = 0;
        scanf("%lld%lld%lld%lld%lld%lld", &a1, &a2, &b1, &b2, &c1, &c2);
        if(a1*b2 == a2*b1 && (a1*b1<0 || a2*b2<0))
            rez++;
        if(c1*b2 == c2*b1 && (b1*c1<0 || b2*c2<0))
            rez++;
        if(a1*c2 == a2*c1 && (a1*c1<0 || a2*c2<0))
            rez++;
        if(isInside(a1, a2, b1, b2, c1, c2, 0, 0))
            rez++;
        printf("%lld", rez);
        return 0;
    }
    LLI x[n - 1], y, f = 0, less = 0, great = 0, rez;
    scanf("%lld", &y);
    for(int i = 0; i < n - 1; i++){
        scanf("%lld", &x[i]);
        scanf("%lld", &x[i]);
    }
    scanf("%lld", &empt);
/*    for(int i = 0; i < n - 1; i++){
        printf("%lld", x[i]);
    }*/
    for(int i = 0; i < n - 1; i++){
        if(x[i] == y)
            f++;
        else if(x[i] >= y)
            great++;
        else if(x[i] < y)
            less++;
    }
    rez = ((cal_pow(less) - 1) * (cal_pow(great) - 1)) % mod;
    if(f) {
        rez += cal_pow(n - 2);
        rez = rez % mod;
    }
    printf("%lld", rez);
    return 0;
}