#include <iostream>
#include <vector>
using namespace std;
struct Point {
long long x, y;
};
// Function to check if a point is on the edge of a polygon segment
bool onEdge(Point p, Point a, Point b) {
long long crossProduct = (b.y - a.y) * (p.x - a.x) - (b.x - a.x) * (p.y - a.y);
if (crossProduct != 0)
return false;
long long dotProduct = (p.x - a.x) * (b.x - a.x) + (p.y - a.y) * (b.y - a.y);
if (dotProduct < 0)
return false;
long long squaredLengthBA = (b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y);
return dotProduct <= squaredLengthBA;
}
// Function to determine if a point is inside the polygon using the Ray-Casting algorithm
bool isInsidePolygon(vector<Point>& polygon, Point p) {
int n = polygon.size();
int intersections = 0;
for (int i = 0; i < n; i++) {
Point a = polygon[i];
Point b = polygon[(i + 1) % n];
// Check if the point is on the edge of the polygon
if (onEdge(p, a, b))
return false; // Point is not strictly inside if it's on the edge
// Check if a ray starting from the point intersects with the edge
if ((p.y > a.y) != (p.y > b.y)) {
double xIntersection = a.x + (double)(b.x - a.x) * (p.y - a.y) / (b.y - a.y);
if (p.x < xIntersection)
intersections++;
}
}
// The point is strictly inside if there are an odd number of intersections
return intersections % 2 == 1;
}
int main() {
int n;
cin >> n;
vector<Point> polygon(n);
for (int i = 0; i < n; i++) {
cin >> polygon[i].x >> polygon[i].y;
}
Point p;
cin >> p.x >> p.y;
if (isInsidePolygon(polygon, p)) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}