#include <bits/stdc++.h>
using namespace std;
int n, re;
long long ans;
long long stck[100010];
bool chstck[100010];
bool over;
int main() {
  scanf("%d", &n);
  stck[0] = 1;
  chstck[0] = true;
  for (int i = 1; i <= n; i++) {
    char in[10];
    scanf("%s", in);
    if (in[0] == 'a') {
      ans += stck[re];
      if (ans >= 4294967296 || !chstck[re]) {
        over = true;
      }
    }
    if (in[0] == 'f') {
      int num;
      scanf("%d", &num);
      stck[re + 1] = stck[re] * num;
      ++re;
      if (stck[re] < 4294967296 && chstck[re - 1])
        chstck[re] = true;
      else
        chstck[re] = false;
    }
    if (in[0] == 'e') {
      re--;
    }
  }
  if (over) {
    printf("OVERFLOW!!!");
    return 0;
  }
  printf("%lld", ans);
}

23
for 84
for 84
for 84
for 84
for 84
for 40
for 40
for 40
for 40
for 40
for 40
add
end
end
end
end
end
end
end
end
end
end
end

5 for 5 end for 2 end add end for 1 end add end

9
add
for 43
end
for 10
for 15
add
end
add
end

5 for 3 end for 2 end add end for 1 end add end

40
for 61
for 28
for 84
add
end
end
add
end
add
add
for 27
for 55
for 70
for 81
add
add
for 23
for 89
for 97
for 58
for 83
add
for 42
add
add
for 100
for 75
add
end
end
end
end
end
end
end
end
end
end
end
end

11
for 100
for 100
for 100
for 100
for 100
add
end
end
end
end
end

15
for 10
add
add
for 20
add
end
add
for 10
add
end
add
for 10
add
end
end

13
for 100
for 100
for 100
for 100
for 100
for 1
add
end
end
end
end
end
end

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class q5 {

	public static void main(String[] args) throws IOException {

		Reader.init(System.in);
		PrintWriter out=new PrintWriter(System.out);
		StringBuffer output=new StringBuffer("");
		int l=Reader.nextInt();
		long start=0;
		long pos=0;
		long val2=(long)Math.pow(2, 32)-1;
		Stack<Long> stk=new Stack<Long>();
		stk.push((long)1);

		while(l>0) {
			l--;
			String s=Reader.next();
			if(s.equals("add")) {
				if(pos==0) {
					long a=stk.peek();
					if(a==-1) pos=-1;
					else
					start+=stk.peek();
					if(start>val2) pos=1;
				}
			}
			else if(s.equals("end")) {
				stk.pop();
			}
			else {
				int n=Reader.nextInt();
				long a=stk.peek();
				if(a==-1) stk.push(a);
				else {
					if(a*n<=val2)
						stk.push(stk.peek()*n);
					else {
						stk.push((long)-1);
					}
				}
			}

		}
		if(pos==0) {
			out.println(start);
		}
		else out.println("OVERFLOW!!!");
		out.println();
		out.flush();

		}
	}

class NoD{
	int a;int b, c;
	String s;

	NoD(int aa,int bb, int cc){
		a=aa;b=bb;c=cc;
	}
	@Override
	public boolean equals(Object o) {
		if(o!=null && o.getClass()==getClass()) {
			NoD c= (NoD) o;
			return c.a==a && c.b==b;
		}
		return false;
	}
	@Override
	public int hashCode() {
		return s.hashCode();
	}
}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
    /** get next word */
    static String nextLine() throws IOException{
    	return reader.readLine();
    }
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }
    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}


n = int(input())
s = list(input())
if n % 2 == 1:
    print(":(")
else:
    op = n // 2 - s.count("(")
    for i in range(n):
        if s[i] == "?":
            if op > 0:
                s[i] = "("
            else:
                s[i] = ")"
            op -= 1
    #print("".join(s))
    b = 0
    for i in range(n):
        if s[i] == ")":
            b -= 1
        else:
            b += 1
        if i != n - 1 and b <= 0:
            print(":(")
            break
    else:
        if b == 0:
            print("".join(s))
        else:
            print(":(")


a, b, c = map(int, input().split())
m = max(a, b, c)
n = a+b+c-m
if n<=m:
	print(m-n+1)
else:
	print(0)

#include <bits/stdc++.h>
using namespace std;
int a, b, c, res;
int main() {
  cin >> a >> b >> c;
  vector<int> v = {a, b, c};
  sort(v.begin(), v.end());
  while (v[0] + v[1] <= v[2]) v[0]++, res++;
  cout << res << endl;
  return 0;
}


n, k1, k2 = map(int, input().split())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

e = []
for i in range(n):
    e.append(abs(a1[i]-a2[i]))
#print(e)

for k in range(k1+k2):
    e[e.index(max(e))] = abs(max(e) - 1)

print(sum(i * i for i in e))

#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  ;
  int n, k1, k2;
  cin >> n >> k1 >> k2;
  k1 += k2;
  int a[n], b[n];
  long long c[n];
  for (long long i = 0; i < (long long)(n); i++) cin >> a[i];
  for (long long i = 0; i < (long long)(n); i++) cin >> b[i];
  for (long long i = 0; i < (long long)(n); i++) c[i] = abs(a[i] - b[i]);
  sort(c, c + n);
  reverse(c, c + n);
  while (k1--) {
    c[0] ? c[0]-- : c[0]++;
    sort(c, c + n);
    reverse(c, c + n);
  }
  long long ans = 0;
  for (long long i = 0; i < (long long)(n); i++) ans += c[i] * c[i];
  cout << ans;
  return 0;
}


# ---------------------------iye ha aam zindegi---------------------------------------------
import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
#import threading
from collections import defaultdict
#threading.stack_size(10**8)
mod = 10 ** 9 + 7
mod1 = 998244353

# ------------------------------warmup----------------------------
import os
import sys
from io import BytesIO, IOBase
#sys.setrecursionlimit(300000)

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# -------------------game starts now----------------------------------------------------import math
class TreeNode:
    def __init__(self, k, v):
        self.key = k
        self.value = v
        self.left = None
        self.right = None
        self.parent = None
        self.height = 1
        self.num_left = 1
        self.num_total = 1

class AvlTree:

    def __init__(self):
        self._tree = None

    def add(self, k, v):
        if not self._tree:
            self._tree = TreeNode(k, v)
            return
        node = self._add(k, v)
        if node:
            self._rebalance(node)

    def _add(self, k, v):
        node = self._tree
        while node:
            if k < node.key:
                if node.left:
                    node = node.left
                else:
                    node.left = TreeNode(k, v)
                    node.left.parent = node
                    return node.left
            elif node.key < k:
                if node.right:
                    node = node.right
                else:
                    node.right = TreeNode(k, v)
                    node.right.parent = node
                    return node.right
            else:
                node.value = v
                return

    @staticmethod
    def get_height(x):
        return x.height if x else 0

    @staticmethod
    def get_num_total(x):
        return x.num_total if x else 0

    def _rebalance(self, node):

        n = node
        while n:
            lh = self.get_height(n.left)
            rh = self.get_height(n.right)
            n.height = max(lh, rh) + 1
            balance_factor = lh - rh
            n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
            n.num_left = 1 + self.get_num_total(n.left)

            if balance_factor > 1:
                if self.get_height(n.left.left) < self.get_height(n.left.right):
                    self._rotate_left(n.left)
                self._rotate_right(n)
            elif balance_factor < -1:
                if self.get_height(n.right.right) < self.get_height(n.right.left):
                    self._rotate_right(n.right)
                self._rotate_left(n)
            else:
                n = n.parent

    def _remove_one(self, node):
        """
        Side effect!!! Changes node. Node should have exactly one child
        """
        replacement = node.left or node.right
        if node.parent:
            if AvlTree._is_left(node):
                node.parent.left = replacement
            else:
                node.parent.right = replacement
            replacement.parent = node.parent
            node.parent = None
        else:
            self._tree = replacement
            replacement.parent = None
        node.left = None
        node.right = None
        node.parent = None
        self._rebalance(replacement)

    def _remove_leaf(self, node):
        if node.parent:
            if AvlTree._is_left(node):
                node.parent.left = None
            else:
                node.parent.right = None
            self._rebalance(node.parent)
        else:
            self._tree = None
        node.parent = None
        node.left = None
        node.right = None

    def remove(self, k):
        node = self._get_node(k)
        if not node:
            return
        if AvlTree._is_leaf(node):
            self._remove_leaf(node)
            return
        if node.left and node.right:
            nxt = AvlTree._get_next(node)
            node.key = nxt.key
            node.value = nxt.value
            if self._is_leaf(nxt):
                self._remove_leaf(nxt)
            else:
                self._remove_one(nxt)
            self._rebalance(node)
        else:
            self._remove_one(node)

    def get(self, k):
        node = self._get_node(k)
        return node.value if node else -1

    def _get_node(self, k):
        if not self._tree:
            return None
        node = self._tree
        while node:
            if k < node.key:
                node = node.left
            elif node.key < k:
                node = node.right
            else:
                return node
        return None

    def get_at(self, pos):
        x = pos + 1
        node = self._tree
        while node:
            if x < node.num_left:
                node = node.left
            elif node.num_left < x:
                x -= node.num_left
                node = node.right
            else:
                return (node.key, node.value)
        raise IndexError("Out of ranges")

    @staticmethod
    def _is_left(node):
        return node.parent.left and node.parent.left == node

    @staticmethod
    def _is_leaf(node):
        return node.left is None and node.right is None

    def _rotate_right(self, node):
        if not node.parent:
            self._tree = node.left
            node.left.parent = None
        elif AvlTree._is_left(node):
            node.parent.left = node.left
            node.left.parent = node.parent
        else:
            node.parent.right = node.left
            node.left.parent = node.parent
        bk = node.left.right
        node.left.right = node
        node.parent = node.left
        node.left = bk
        if bk:
            bk.parent = node
        node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
        node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
        node.num_left = 1 + self.get_num_total(node.left)

    def _rotate_left(self, node):
        if not node.parent:
            self._tree = node.right
            node.right.parent = None
        elif AvlTree._is_left(node):
            node.parent.left = node.right
            node.right.parent = node.parent
        else:
            node.parent.right = node.right
            node.right.parent = node.parent
        bk = node.right.left
        node.right.left = node
        node.parent = node.right
        node.right = bk
        if bk:
            bk.parent = node
        node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
        node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
        node.num_left = 1 + self.get_num_total(node.left)

    @staticmethod
    def _get_next(node):
        if not node.right:
            return node.parent
        n = node.right
        while n.left:
            n = n.left
        return n

# -----------------------------------------------binary seacrh tree---------------------------------------
class SegmentTree1:
    def __init__(self, data, default=300006, func=lambda a, b: min(a , b)):
        """initialize the segment tree with data"""
        self._default = default
        self._func = func
        self._len = len(data)
        self._size = _size = 1 << (self._len - 1).bit_length()

        self.data = [default] * (2 * _size)
        self.data[_size:_size + self._len] = data
        for i in reversed(range(_size)):
            self.data[i] = func(self.data[i + i], self.data[i + i + 1])

    def __delitem__(self, idx):
        self[idx] = self._default

    def __getitem__(self, idx):
        return self.data[idx + self._size]

    def __setitem__(self, idx, value):
        idx += self._size
        self.data[idx] = value
        idx >>= 1
        while idx:
            self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
            idx >>= 1

    def __len__(self):
        return self._len

    def query(self, start, stop):
        if start == stop:
            return self.__getitem__(start)
        stop += 1
        start += self._size
        stop += self._size

        res = self._default
        while start < stop:
            if start & 1:
                res = self._func(res, self.data[start])
                start += 1
            if stop & 1:
                stop -= 1
                res = self._func(res, self.data[stop])
            start >>= 1
            stop >>= 1
        return res

    def __repr__(self):
        return "SegmentTree({0})".format(self.data)

# -------------------game starts now----------------------------------------------------import math
class SegmentTree:
    def __init__(self, data, default=0, func=lambda a, b:a + b):
        """initialize the segment tree with data"""
        self._default = default
        self._func = func
        self._len = len(data)
        self._size = _size = 1 << (self._len - 1).bit_length()

        self.data = [default] * (2 * _size)
        self.data[_size:_size + self._len] = data
        for i in reversed(range(_size)):
            self.data[i] = func(self.data[i + i], self.data[i + i + 1])

    def __delitem__(self, idx):
        self[idx] = self._default

    def __getitem__(self, idx):
        return self.data[idx + self._size]

    def __setitem__(self, idx, value):
        idx += self._size
        self.data[idx] = value
        idx >>= 1
        while idx:
            self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
            idx >>= 1

    def __len__(self):
        return self._len

    def query(self, start, stop):
        if start == stop:
            return self.__getitem__(start)
        stop += 1
        start += self._size
        stop += self._size

        res = self._default
        while start < stop:
            if start & 1:
                res = self._func(res, self.data[start])
                start += 1
            if stop & 1:
                stop -= 1
                res = self._func(res, self.data[stop])
            start >>= 1
            stop >>= 1
        return res

    def __repr__(self):
        return "SegmentTree({0})".format(self.data)

# -------------------------------iye ha chutiya zindegi-------------------------------------
class Factorial:
    def __init__(self, MOD):
        self.MOD = MOD
        self.factorials = [1, 1]
        self.invModulos = [0, 1]
        self.invFactorial_ = [1, 1]

    def calc(self, n):
        if n <= -1:
            print("Invalid argument to calculate n!")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        if n < len(self.factorials):
            return self.factorials[n]
        nextArr = [0] * (n + 1 - len(self.factorials))
        initialI = len(self.factorials)
        prev = self.factorials[-1]
        m = self.MOD
        for i in range(initialI, n + 1):
            prev = nextArr[i - initialI] = prev * i % m
        self.factorials += nextArr
        return self.factorials[n]

    def inv(self, n):
        if n <= -1:
            print("Invalid argument to calculate n^(-1)")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        p = self.MOD
        pi = n % p
        if pi < len(self.invModulos):
            return self.invModulos[pi]
        nextArr = [0] * (n + 1 - len(self.invModulos))
        initialI = len(self.invModulos)
        for i in range(initialI, min(p, n + 1)):
            next = -self.invModulos[p % i] * (p // i) % p
            self.invModulos.append(next)
        return self.invModulos[pi]

    def invFactorial(self, n):
        if n <= -1:
            print("Invalid argument to calculate (n^(-1))!")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        if n < len(self.invFactorial_):
            return self.invFactorial_[n]
        self.inv(n)  # To make sure already calculated n^-1
        nextArr = [0] * (n + 1 - len(self.invFactorial_))
        initialI = len(self.invFactorial_)
        prev = self.invFactorial_[-1]
        p = self.MOD
        for i in range(initialI, n + 1):
            prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p
        self.invFactorial_ += nextArr
        return self.invFactorial_[n]

class Combination:
    def __init__(self, MOD):
        self.MOD = MOD
        self.factorial = Factorial(MOD)

    def ncr(self, n, k):
        if k < 0 or n < k:
            return 0
        k = min(k, n - k)
        f = self.factorial
        return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

# --------------------------------------iye ha combinations ka zindegi---------------------------------
def powm(a, n, m):
    if a == 1 or n == 0:
        return 1
    if n % 2 == 0:
        s = powm(a, n // 2, m)
        return s * s % m
    else:
        return a * powm(a, n - 1, m) % m

# --------------------------------------iye ha power ka zindegi---------------------------------
def sort_list(list1, list2):
    zipped_pairs = zip(list2, list1)

    z = [x for _, x in sorted(zipped_pairs)]

    return z

# --------------------------------------------------product----------------------------------------
def product(l):
    por = 1
    for i in range(len(l)):
        por *= l[i]
    return por

# --------------------------------------------------binary----------------------------------------
def binarySearchCount(arr, n, key):
    left = 0
    right = n - 1

    count = 0

    while (left <= right):
        mid = int((right + left) / 2)

        # Check if middle element is
        # less than or equal to key
        if (arr[mid] <key):
            count = mid + 1
            left = mid + 1

        # If key is smaller, ignore right half
        else:
            right = mid - 1

    return count

# --------------------------------------------------binary----------------------------------------
def countdig(n):
    c = 0
    while (n > 0):
        n //= 10
        c += 1
    return c
def binary(x, length):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y

def countGreater(arr, n, k):
    l = 0
    r = n - 1

    # Stores the index of the left most element
    # from the array which is greater than k
    leftGreater = n

    # Finds number of elements greater than k
    while (l <= r):
        m = int(l + (r - l) / 2)
        if (arr[m] >= k):
            leftGreater = m
            r = m - 1

        # If mid element is less than
        # or equal to k update l
        else:
            l = m + 1

    # Return the count of elements
    # greater than k
    return (n - leftGreater)

# --------------------------------------------------binary------------------------------------
class TrieNode:
    def __init__(self):
        self.children = [None] * 26
        self.isEndOfWord = False
class Trie:
    def __init__(self):
        self.root = self.getNode()
    def getNode(self):
        return TrieNode()
    def _charToIndex(self, ch):
        return ord(ch) - ord('a')
    def insert(self, key):
        pCrawl = self.root
        length = len(key)
        for level in range(length):
            index = self._charToIndex(key[level])
            if not pCrawl.children[index]:
                pCrawl.children[index] = self.getNode()
            pCrawl = pCrawl.children[index]
        pCrawl.isEndOfWord = True
    def search(self, key):
        pCrawl = self.root
        length = len(key)
        for level in range(length):
            index = self._charToIndex(key[level])
            if not pCrawl.children[index]:
                return False
            pCrawl = pCrawl.children[index]
        return pCrawl != None and pCrawl.isEndOfWord
#-----------------------------------------trie---------------------------------
class Node:
    def __init__(self, data):
        self.data = data
        self.height=0
        self.left = None  # left node for 0
        self.right = None  # right node for 1
class BinaryTrie:
    def __init__(self):
        self.root = Node(0)
    def insert(self, pre_xor):
        self.temp = self.root
        for i in range(31, -1, -1):
            val = pre_xor & (1 << i)
            if val==0:
                if not self.temp.right:
                    self.temp.right = Node(0)
                self.temp = self.temp.right
            elif val>=1:
                if not self.temp.left:
                    self.temp.left = Node(0)
                self.temp = self.temp.left
    def do(self,temp):
        if not temp:
            return 0
        ter=temp
        temp.height=self.do(ter.left)+self.do(ter.right)
        if temp.height==0:
            temp.height+=1
        return temp.height
    def query(self, xor):
        self.temp = self.root
        cur=0
        i=31
        while(i>-1):
            val = xor & (1 << i)
            if not self.temp:
                return cur
            if val>=1:
                self.opp = self.temp.right
                if self.temp.left:
                    self.temp = self.temp.left
                else:
                   return cur
            else:
                self.opp=self.temp.left
                if self.temp.right:
                   self.temp = self.temp.right
                else:
                   return cur
            if self.temp.height==pow(2,i):
                cur+=1<<(i)
                self.temp=self.opp
            i-=1
        return cur
#-------------------------bin trie-------------------------------------------
n=int(input())
l=[]
w=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append((a,b))
    w.append(a)
    w.append(b)
    w.append(a-1)
    w.append(a+1)
    w.append(b-1)
    w.append(b+1)
w=sorted(set(w))
ind=defaultdict(int)
for i in range(len(w)):
    ind[w[i]]=i
e=[0]*(len(w)+1)
for i in range(n):
    a,b=l[i]
    a1=ind[a]
    b1=ind[b+1]
    e[a1]+=1
    e[b1]-=1
for i in range(1,len(w)):
    e[i]+=e[i-1]
s=SegmentTree1(e)
f=0
for i in range(n):
    a,b=l[i]
    a1 = ind[a]
    b1 = ind[b]
    if s.query(a1,b1)>1:
        print(i+1)
        f=1
        break
if f==0:
    print(-1)

4 1 2 3 4 5 16 17 18
```

Note that the length of each sample input is within the limit of 40 tokens.

#include <bits/stdc++.h>
const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;
const int inf = 2e8;
using namespace std;
struct node {
  int l, r, i;
  bool friend operator<(node a, node b) {
    if (a.l == b.l) return a.r < b.r;
    return a.l < b.l;
  }
} a[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].l, &a[i].r);
    a[i].i = i;
  }
  sort(a + 1, a + 1 + n);
  a[0].l = -1, a[0].r = -1, a[n + 1].l = inf, a[n + 1].r = -1;
  for (int i = 1; i <= n; i++) {
    if (a[i - 1].l <= a[i].l && a[i - 1].r >= a[i].r) {
      cout << a[i].i << endl;
      return 0;
    } else if (a[i].l == a[i + 1].l && a[i + 1].r >= a[i].r) {
      cout << a[i].i << endl;
      return 0;
    } else if (a[i - 1].r >= a[i + 1].l - 1) {
      if (a[i - 1].l <= a[i].l && a[i + 1].r >= a[i].r) {
        cout << a[i].i << endl;
        return 0;
      }
    }
  }
  cout << "-1" << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
string s;
int cnt[26];
stack<char> st;
int main() {
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    cnt[s[i] - 'a']++;
  }
  int index = 0;
  for (int i = 0; i < s.length(); i++) {
    cnt[s[i] - 'a']--;
    while (index < 26 && cnt[index] == 0) {
      index++;
    }
    if (index < s[i] - 'a')
      st.push(s[i]);
    else {
      while (!st.empty()) {
        if (st.top() > s[i]) break;
        cout << st.top();
        st.pop();
      }
      cout << s[i];
      while (!st.empty()) {
        if (st.top() > 'a' + index) break;
        cout << st.top();
        st.pop();
      }
    }
  }
  while (!st.empty()) {
    cout << st.top();
    st.pop();
  }
  cout << endl;
  return 0;
}

hgf bbbb azxy efgh hge hgf babcaaccb hge acdb acde aabc dbca abcd badbdc efgh xyza acdb xyza edca xyzw abce efgh xyza adcb dcba efgh cab dcba abcd efgh hge ecba abcc efgh hge bcda azxy aabbb bcda hge efgh abcd aaaa efgh efgh hgf cab zyxw hgf azxy

abce aaabcccbb egh egh efgh egh acde abcd acde egh abcd azyx wxyz axyz abbcdd abcd efgh abcd axyz bbbb efgh efgh abdc abce abc adcb efgh axyz adcb abcc efgh fgh abdc fgh efgh aabbb wzyx fgh acbd azyx aabc abc egh abcd efgh fgh azyx efgh abcd aaaa

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;

/**
 *
 * @author ehab
 */
public class JavaApplication1 {

    static long totalcost [] , saving[] , indcost [] ;
    static boolean is[] ;
    static int getMin(){
     int ind = -1 ;
    long min = Integer.MAX_VALUE ;
        for(int i = 0 ; i < totalcost.length ; i++)
          if(!is[i])
          {
           if(totalcost[i]-(saving[i]*indcost[i]) < min)
           {
            min = totalcost[i]-(saving[i]*indcost[i]) ;
            ind = i ;
           }
          }

    return ind ;
    }
    public static void main(String[] args) throws Exception
    {
        Reader.init(System.in);

        StringBuilder ans = new StringBuilder() ;
        String s = Reader.next() ;
        PriorityQueue<pair> pr = new PriorityQueue<pair>() ;
        for(int i = 0 ; i < s.length() ; i++)
            pr.add(new pair(s.charAt(i) , i)) ;

        Stack<pair> st = new Stack<pair>() ;
        st.add(new pair(s.charAt(0) , 0));
        int stakInd = 1 ;

        while(!pr.isEmpty())
        {
         pair p = pr.poll() ;
         while(!st.isEmpty() && st.peek().a <= p.a)
         {
          ans.append( (char)(st.pop().a) +"") ;

         }
         if(stakInd <= p.b)
         {
           for(int i = stakInd ; i <= p.b ; i++ , stakInd++)
            st.push(new pair(s.charAt(stakInd) , i)) ;
           ans.append((char)st.pop().a) ;

         }

        }
        System.out.println(ans);

        }

    }

 class pair implements Comparable<pair>
    {
     int  a , b;

    pair(int a , int b)
    {
    this.a = a ;
    this.b = b ;

    }

    public int compareTo(pair t) {
        if(t.a < a)
            return 1 ;
        else if(t.a > a)
            return -1;
        else if(t.b < b ) return 1 ;
        else if(t.b > b) return -1 ;
        else return 0 ;
    }

    }

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {

            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
	 static int nextShort() throws IOException {
        return Short.parseShort(next() );
    }
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException{
    return Long.parseLong(next()) ;
    }
}


import math, sys
def solve():
	bx,by = map(int, input().split())
	dist = lambda f1, f2, v: math.sqrt(f1*f1+f2*f2) / v
	n = int(input())
	ans = sys.maxsize
	for _ in range(n):
		x,y,v = map(int, input().split())
		ans = min(ans, dist(x-bx, y-by,v))
	return ans

print(solve())

import java.util.*;
import java.lang.Math.*;

public class Main{
	public static void main(String[] args){
		solve();
	}
	public static void solve(){
		Scanner scan = new Scanner(System.in);
		int n;
		double xa, ya, va, t, x0, y0;
		x0 = scan.nextDouble();
		y0 = scan.nextDouble();
		n = scan.nextInt();
		xa = va = ya = 0;
		for(int i = 1; i <= n; i++){
			double x, y, v;
			x = scan.nextDouble();
			y = scan.nextDouble();
			v = scan.nextDouble();
			if((i == 1) || ((i != 1) && (rast(x0, y0, xa, ya) * v * v > rast(x0, y0, x, y) * va * va))){
				xa = x;
				ya = y;
				va = v;
			}
		}
		t = Math.sqrt(rast(x0, y0, xa, ya)) / va;
		System.out.println(t);
		//System.out.println(xa + " " + ya + " " + va + " rast = " + rast(x0, y0, xa, ya));
	}
	public static double rast(double x1, double y1, double x2, double y2){
		return ((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2));
	}
}


import java.util.*;

public class Game{
	public static void main (String args[]){
		Scanner kb = new Scanner(System.in);
		long i = kb.nextLong();

		if( (2 -  ( i % 2)) == 2 )
			System.out.print(2);
		else
			System.out.print(1);

	}
}

n = int(input(""))
if n % 2 == 0:
    print (2)
else:
    print (1)


#include <bits/stdc++.h>
using namespace std;
vector<int> a;
int main() {
  int N, K, P, X, Y;
  int l, m;
  cin >> N >> K >> P >> X >> Y;
  int sum = 0;
  for (int i = 0; i < K; ++i) {
    cin >> l;
    a.push_back(l);
    sum += a[i];
  }
  sort(a.begin(), a.end());
  l = X - sum;
  if (K >= ((N + 1) / 2) && a[((N + 1) / 2 - 1)] < Y) {
    cout << "-1" << endl;
    return 0;
  }
  int p = ((N + 1) / 2) - 1;
  m = lower_bound(a.begin(), a.end(), Y) - a.begin();
  int lef = p - m;
  int rig = N - (K + lef);
  if (rig < 0) {
    lef += rig;
    rig = 0;
  }
  if ((lef + rig * Y) > l) {
    cout << "-1" << endl;
    return 0;
  }
  for (int i = 0; i < lef; ++i)
    cout << "1"
         << " ";
  for (int i = 0; i < rig; ++i) cout << Y << " ";
  cout << endl;
  return 0;
}

5 3 5 42 4 3 5 4
```

Note that these inputs are random and may not necessarily result in valid

import java.util.Scanner;

public class Marks {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int p = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int sum = 0;
        int e;
        int lm = 0;
        int gm = 0;
        int [] res = new int[n - k];
        int c = 0;
        for (int i = 0; i < k; ++i) {
            e = sc.nextInt();
            sum += e;
            if (e >= y) {gm++;}
            else {lm++;}
        }
        if (lm > (n - 1) / 2) {
            System.out.println(-1);
            return;
        }

        int minY = (n + 1)/2 - gm;
        if (minY > 0) {
            for (int i = 0; i < minY; ++i) {
                res[c++] = y;
                sum+= y;
            }
        }
        if (sum > x) {
            System.out.println(-1);
            return;
        } else {
            for (int i = c; i < res.length; ++i) {
                res[i] = 1;
                sum++;
            }
        }
        if (sum > x) {
            System.out.println(-1);
            return;
        }
        else {
            for (int i : res) {
                System.out.print(i + " ");
            }
        }
    }
}


import java.util.*;
import java.io.*;
public class MyClass {
    public static void main(String args[]) {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String s = br.readLine();
            String rs = "";
            // if(s.equals("9")){
            //     System.out.println(9);
            //     return;
            // }
            for(int i=0;i<s.length();i++){
                int v = s.charAt(i)-'0';
                int sv = 9-v;
                if((i==0 && v==9)){
                    rs+=v;
                }
                else if(sv<5){
                    rs+=sv;
                }else{
                    rs+=v;
                }
            }
            System.out.println(rs);
        }catch(Exception e){
            System.out.println(e);
        }
    }
}


import java.util.Scanner;

public class Solution {

    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
       int[][] students= new int[3][n];
       int[] indexes = {0,0,0};
       int subject ;
       for(int i = 1; i<=n; i++){
           subject = sc.nextInt();
           students[subject - 1][indexes[subject - 1]++] += i;
       }
      int n_teams = Math.min(indexes[0] , Math.min(indexes[1] , indexes[2] ));
      System.out.println(n_teams);
      for(int i = 0; i<n_teams; i++){
          System.out.println(students[0][i] + " " + students[1][i] + " " + students[2][i]);
      }
    }

}

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, mn;
  cin >> n;
  vector<int> v1, v2, v3;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if (x == 1) {
      v1.push_back(i);
    } else if (x == 2) {
      v2.push_back(i);
    } else {
      v3.push_back(i);
    }
  }
  mn = min(min(v1.size(), v2.size()), v3.size());
  cout << mn << "\n";
  for (int i = 0; i < mn; i++) {
    cout << v1[i] << " " << v2[i] << " " << v3[i] << "\n";
  }
  return 0;
}


import java.io.BufferedInputStream;
import java.util.Scanner;

public class MartianDollar { //Round #40 - Martian Dollar
	public static void main(String[] args) {
		Scanner sc = new Scanner(new BufferedInputStream(System.in));

		int numDays = sc.nextInt();
		int[] dollarCourses = new int[numDays];
		int bourlesAmount = sc.nextInt();
		for(int i = 0; i < dollarCourses.length; i++) {
			dollarCourses[i] = sc.nextInt();
		}

		int maxBourles = 0;

		for(int i = 0; i < dollarCourses.length; i++) {
			int takeOutDollars = bourlesAmount / dollarCourses[i];
			int remainingBourles = bourlesAmount % dollarCourses[i];

			for(int j = 0; j < dollarCourses.length; j++) {
				if(j >= i) {
					int resultBourles = remainingBourles + takeOutDollars * dollarCourses[j];

					if(resultBourles > maxBourles) {
						maxBourles = resultBourles;
					}
				}
			}
		}

		System.out.println(maxBourles);
	}
}

I = lambda : map(int,input().split())
n,m = I()
li = list(I())
ma = li[n-1]
ans=m
for i in range(n-2,-1,-1) :
    ma=max(ma,li[i])
    ans = max(ans,m%li[i]+(m//li[i])*(ma))
print(ans)


import java.util.Scanner;

public class OnSegmentsOwnPoints {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        boolean[] vis = new boolean[101];
        int l1 = in.nextInt(), r1 = in.nextInt();
        for (int i = 1; i < n; ++i) {
            int l = in.nextInt(), r = in.nextInt();
            for (int j = l; j < r; ++j)
                vis[j] = true;
        }
        int cnt = 0;
        for (int i = l1; i < r1; ++i)
            cnt += vis[i] ? 0 : 1;
        System.out.println(cnt);
    }
}

n=int(input())
d=[1]*100
a,b=map(int,input().split())
for i in range(n-1):
    l,r=map(int,input().split())
    for i in range(l,r):
        d[i]=0
print(sum(d[a:b]))


#include <bits/stdc++.h>
using namespace std;
long long quickPow(long long x, long long n, long long p) {
  long long res = 1, bas = x;
  while (n) {
    if (n & 1) res = res * bas % p;
    bas = bas * bas % p;
    n >>= 1;
  }
  return res;
}
bool isPrime(int a) {
  for (int i = 2; i * i <= a; i++)
    if (a % i == 0) return 0;
  return 1;
}
long long ans;
int p[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
void dfs(int dep, int num, long long temp, int up, int n) {
  if (num > n || dep >= 16) return;
  if (num == n && temp < ans) {
    ans = temp;
    return;
  }
  for (int i = 1; i <= up; i++) {
    if (temp > ans) break;
    dfs(dep + 1, num * (i + 1), temp = temp * p[dep], i, n);
  }
}
int main() {
  int n;
  cin >> n;
  ans = 1e18;
  dfs(0, 1, 1, 64, n);
  cout << ans << endl;
  return 0;
}


n=int(input())
count=0
for _ in range(n):
    l=list(map(int,input().split()))
    if(sum(l)>=2):
        count+=1
print(count)

import java.util.*;

public class test {

	private static final Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
				int n=sc.nextInt();
			int c=0;
			for(int i=0;i<n;i++)
			{
				int c0=0;
				int c1=0;
				int x=3;
				while(x>0)
				{
					int k=sc.nextInt();
					if(k==0)
						++c0;
					else
						++c1;
					x--;
				}
				if(c1>=2)
				{
					++c;
				}
			}
			System.out.println(c);

	}
}


import java.io.*;
import java.util.*;

public class E {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();

		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();

		long ans = 0;

		int maxP = m / n;
		for (int p = 1; p <= maxP; p++) {
			long minLastSum = (long)p * (p + 1) / 2 * n;
			if (a[n - 1] < minLastSum)
				continue;
			long maxLastSum = (long)m * p - (long)n * p * (p - 1) / 2;
			long[] money = new long[n];
			money[n - 1] = Math.min(maxLastSum, a[n - 1]);
			for (int i = n - 2; i >= 0; i--)
				money[i] = Math.min(a[i], money[i + 1] - p);

			long firstMax = (long)(m + 1) * p - (long)n * p * (p + 1) / 2;
			long diff = firstMax - money[0];
			if (diff < 0)
				throw new AssertionError();
			long firstPay = diff <= m - p * n ? (m - p * n + 1 - diff) : 1;
			long free = (m - firstPay + 1) - n * p;

			long cur = money[0];
			long last = money[0];
			for (int j = 1; j < n; j++) {
				long now = last + p;
				long shift = Math.min(free, money[j] - now);
				free -= shift;
				last = now + shift;
				cur += last;
			}

			ans = Math.max(ans, cur);
		}

		out.println(ans);
	}

	void inp() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new E().inp();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

#include <bits/stdc++.h>
using namespace std;
long long i, j, k, p, n, m, ans, Mi, Ma;
long long a[200000 + 10];
long long Calc(long long Mini, long long Maxi) {
  long long res = 0;
  Ma = ((Ma) < (a[n]) ? (Ma) : (a[n]));
  for (i = 1; i < n; ++i)
    Ma = ((Ma) < (a[i] - (i - 1) * Mini + Maxi)
              ? (Ma)
              : (a[i] - (i - 1) * Mini + Maxi));
  long long x = Ma;
  for (i = n; i >= 1; --i) {
    if (i != n) x -= Mini;
    x = ((x) < (a[i]) ? (x) : (a[i]));
    if (x < Mi || Ma > x + Maxi) return -1;
    res += x;
  }
  return res;
}
int main() {
  scanf(
      "%I64d"
      "%I64d"
      "\n",
      &n, &m);
  for (i = 1; i <= n; ++i) scanf("%I64d", a + i);
  for (long long t = 1; t * n <= m; ++t) {
    long long v = t * (t - 1) / 2 * n;
    Mi = v + t, Ma = m * t - v;
    ans = ((ans) > (Calc(t, m - t)) ? (ans) : (Calc(t, m - t)));
  }
  printf(
      "%I64d"
      "\n",
      ans);
  return 0;
}


n = int(input())
parent = [0] + [x-1 for x in list(map(int, input().split()))]
citizen = list(map(int, input().split()))

sz = [1] * n
for i in range(1, n):
    sz[parent[i]] = 0
#print(sz)
for i in range(n-1, 0, -1):
    citizen[parent[i]] += citizen[i]
    sz[parent[i]] += sz[i]
#print(citizen)
#print(sz)
ans = 0
for i in range(n):
    if citizen[i]%sz[i]==0:
        ans=max(ans,citizen[i]//sz[i])
    else:
        ans=max(ans,(citizen[i]//sz[i])+1)
    #ans = max(ans, (citizen[i]+sz[i]-1)//sz[i])

print(ans)

#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const int MOD = 1000000007;
int n;
int a[N];
vector<int> edges[N];
tuple<long long, int, long long> dfs(int u) {
  long long sum = a[u], ans = 0LL;
  int leaf = (edges[u].size() == 0);
  for (int v : edges[u]) {
    long long nsum, nans;
    int nleaf;
    tie(nsum, nleaf, nans) = dfs(v);
    sum += nsum;
    leaf += nleaf;
    ans = max(ans, nans);
  }
  ans = max(ans, sum / leaf + (sum % leaf > 0));
  return make_tuple(sum, leaf, ans);
}
int solve() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int p;
    scanf("%d", &p);
    --p;
    edges[p].push_back(i);
  }
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  printf("%lld\n", get<2>(dfs(0)));
  return 0;
}
int main() {
  int t = 1;
  for (int tc = 0; tc < t; ++tc) {
    solve();
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h, u1, d1, u2, d2, i;
  cin >> w >> h >> u1 >> d1 >> u2 >> d2;
  for (i = h; i > 0; i--) {
    w += i;
    if (i == d1) {
      w = w - u1;
      if (w < 0) w = 0;
    } else if (i == d2) {
      w = w - u2;
      if (w < 0) w = 0;
    }
  }
  cout << w;
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		Reader in = new Reader();
		int[] a = in.na(6);
		int w = a[0];
		int h = a[1];
		while(h>0) {
			w+=h;
			if(h==a[3]) w-=a[2];
			else if(h==a[5]) w-=a[4];
			w = Math.max(0, w);
			h--;
		}
		System.out.println(w);
	}

	static class Reader {
		static BufferedReader br;
		static StringTokenizer st;
		public Reader() {
			this.br = new BufferedReader(new InputStreamReader(System.in));
		}
		public int[] na(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
		public long[] nl(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++) a[i] = nextLong();
			return a;
		}
		public String[] nS(int n) {
			String[] a = new String[n];
			for (int i = 0; i < n; i++) a[i] = next();
			return a;
		}
		public int nextInt() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Integer.parseInt(st.nextToken());
		}
		public double nextDouble() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Double.parseDouble(st.nextToken());
		}
		public Long nextLong() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Long.parseLong(st.nextToken());
		}
		public String next() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return st.nextToken();
		}
		public static void readLine() {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
			}
		}
	}
}


    import java.util.Scanner;
    import java.math.BigInteger;

    public class Main{
    	public static void main(String [] cats) {
    		Scanner sc = new Scanner(System.in);
    		int cases = sc.nextInt();
    		while (cases > 0) {
    			cases--;
    			BigInteger a = new BigInteger(sc.next());
    			BigInteger b = new BigInteger(sc.next());
    			a = a.multiply(a);
    			b = b.multiply(b);
    			a = a.subtract(b);
    			if (a.isProbablePrime(56)) {
    				System.out.println("YES");
    			} else {
    				System.out.println("NO");
    			}
    		}
    	}
    }

def check(n):
	i=2
	while i*i<=n:
		if n%i==0:
			return 1
		i+=1
	return 0

for _ in range(int(input())):
	a,b=map(int,input().split())
	if (a-b)!=1:
		print('NO')
	else:
		if check((a*a)-(b*b)):print('NO')
		else:print('YES')


#!/usr/bin/env python3

n = int(input().strip())
ais = list(map(int, input().strip().split()))

ais.sort()
cnt = 0
s = sum(ais)
thrs = -((-9 * n) // 2)  # ceil(4.5 * n)
while s < thrs:
	s += 5 - ais[cnt]
	cnt += 1

print (cnt)

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, x, countt = 0;
  cin >> n;
  double d = 0, k = 0;
  vector<long long int> v;
  for (long long int i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
    d += x;
  }
  k = d;
  d = d / (n * 1.0);
  if (d > 4.50)
    cout << 0;
  else {
    sort(v.begin(), v.end());
    for (auto it = v.begin(); it < v.end(); it++) {
      if (*it > 4) break;
      if (*it < 5 && d < 4.5) {
        countt++;
        k += (5 - (*it));
        d = (k / (n * 1.0));
        if (d >= 4.5) {
          break;
        }
      }
    }
    cout << countt;
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint linf = 1e18 + 7;
const lint inf = 1e9 + 7;
const int MOD = 1000000007;
signed main() {
  int n;
  cin >> n;
  cout << n / 2 + 1 << "\n";
  return 0;
}

from collections import deque
import math
import os
import random
import re
import sys
#n=list(map(int, input().split()))
#n=map(int, input().split())

def main():
	n=int(input())
	ans=n//2+1
	print(ans)
main()


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            long n = in.readLong();
            long m = in.readLong();
            int k = in.readInt();
            if (k == -1 && (n + m) % 2 == 1) {
                out.printLine(0);
            } else {
                out.printLine(IntegerUtils.power(IntegerUtils.power(2, n - 1, MiscUtils.MOD7), m - 1, MiscUtils.MOD7));
            }
        }
    }
    static class IntegerUtils {
        public static long power(long base, long exponent, long mod) {
            if (base >= mod) {
                base %= mod;
            }
            if (exponent == 0) {
                return 1 % mod;
            }
            long result = power(base, exponent >> 1, mod);
            result = result * result % mod;
            if ((exponent & 1) != 0) {
                result = result * base % mod;
            }
            return result;
        }
    }
    static class MiscUtils {
        public static final int MOD7 = (int) (1e9 + 7);
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(long i) {
            writer.println(i);
        }

        public void printLine(int i) {
            writer.println(i);
        }
    }
}

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long N = 2e5 + 5;
const long double pi = 3.14159265;
long long gcd(long long a_, long long b_) {
  if (b_ > a_) swap(b_, a_);
  return (b_ == 0 ? a_ : gcd(b_, a_ % b_));
}
long long n, m, k;
long long p(long long d, long long t) {
  if (t == 0) return 1;
  long long tmp = p(d, t / 2);
  if (t % 2) return tmp * tmp % MOD * d % MOD;
  return tmp * tmp % MOD;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  if (k == -1 && (n % 2 != m % 2)) {
    cout << 0;
    return 0;
  }
  cout << p(p(2, n - 1), m - 1);
  return 0;
}


# Legends Always Come Up with Solution
# Author: Manvir Singh

import os
import sys
from io import BytesIO, IOBase
from collections import Counter
from bisect import *
from math import gcd
from itertools import permutations,combinations
from math import sqrt,ceil,floor

def main():
    n,k=map(int,input().split())
    z=floor((-1+sqrt(1+8*k))/2)
    f=int((z*(z+1))//2!=k)
    if z+f>n-1:
        print("Impossible")
    else:
        if f:
            y=((z+1)*(z+2))//2-k
            print("("*(z+1)+")"*y+"("+")"*(z+2-y)+"()"*(n-(z+2)))
        else:
            print("("*(z+1)+")"*(z+1)+"()"*(n-1-z))

# region fastio
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()

#include <bits/stdc++.h>
using namespace std;
void output(int k, int ct) {
  for (int i = 0; i <= k; i++) {
    if (ct && i == ct) printf("()");
    printf("(");
  }
  for (int i = 0; i <= k; i++) printf(")");
}
long long binary(long long l, long long r, long long sum) {
  if (l == r) return l;
  long long m = (l + r) >> 1;
  if ((m + 1) * (m + 2) / 2 <= sum) return binary(m + 1, r, sum);
  return binary(l, m, sum);
}
int main() {
  long long n, sum;
  while (cin >> n >> sum) {
    long long k = binary(0, 2e9, sum);
    long long s = k * (k + 1) / 2;
    long long ct = sum - s;
    long long MIN = k + 1;
    if (ct) MIN++;
    if (n < MIN)
      printf("Impossible\n");
    else {
      for (int i = 0; i < n - MIN; i++) printf("()");
      output(k, ct);
      printf("\n");
    }
  }
  return 0;
}


import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main implements Runnable {

    int maxn = (int)1e5+111;
    int mod = (int)1e9+7;
    int inf = (int)1e9;
    int n,m,k;

    void solve() throws Exception {
        n = in.nextInt();
        int cnt = 0;
        Stack<Integer> stack = new Stack<>();
        int cur = 1;
        for (int i=1; i<=n*2; i++) {
            String type = in.nextToken();
            if (type.equals("add")) {
                int val = in.nextInt();
                stack.add(val);
            } else {
                if (!stack.isEmpty()) {
                    if (stack.peek() == cur) {
                        stack.pop();
                    } else {
                        cnt++;
                        stack.clear();
                    }
                }
                cur++;
            }
        }

        out.println(cnt);
    }

    class Pair {
        int x;
        int y;
        public Pair (int x, int y) {
            this.x = x;
            this.y = y;
        }
        @Override
        public int hashCode() {
            final int prime = 31;
            int result = 1;
            result = prime * result + getOuterType().hashCode();
            result = prime * result + x;
            result = prime * result + y;
            return result;
        }
        @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass())
                return false;
            Pair other = (Pair) obj;
            if (!getOuterType().equals(other.getOuterType()))
                return false;
            if (x != other.x)
                return false;
            if (y != other.y)
                return false;
            return true;
        }
        private Main getOuterType() {
            return Main.this;
        }

    }

    String fileInName = "input.txt";
    boolean file = false;
    boolean isAcmp = true;

    static Throwable throwable;
    public static void main (String [] args) throws Throwable {
        Thread thread = new Thread(null, new Main(), "", (1 << 26));
        thread.start();
        thread.join();
        thread.run();
        if (throwable != null)
            throw throwable;
    }

    FastReader in;
    PrintWriter out;

    public void run() {
        String fileIn = "input.txt";
        String fileOut = "output.txt";

        try {
            if (isAcmp) {
                if (file) {
                    in = new FastReader(new BufferedReader(new FileReader(fileIn)));
                    out = new PrintWriter (fileOut);
                } else {
                    in = new FastReader(new BufferedReader(new InputStreamReader(System.in)));
                    out = new PrintWriter(System.out);
                }
            } else if (file) {
                in = new FastReader(new BufferedReader(new FileReader(fileInName+".in")));
                out = new PrintWriter (fileInName + ".out");
            } else {
                in = new FastReader(new BufferedReader(new InputStreamReader(System.in)));
                out = new PrintWriter(System.out);
            }

            solve();
        } catch(Exception e) {
            throwable = e;
        } finally {
            out.close();
        }

    }
}

class FastReader {
    BufferedReader bf;
    StringTokenizer tk = null;

    public FastReader(BufferedReader bf) {
        this.bf = bf;
    }

    public String nextToken () throws Exception {
        if (tk==null || !tk.hasMoreTokens()) {
            tk = new StringTokenizer(bf.readLine());
        }
        if (!tk.hasMoreTokens()) return nextToken();
        else
            return tk.nextToken();
    }

    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

7
add 3
add 2
add 1
remove
add 4
remove
remove
remove
add 6
add 7
add 5
remove
remove
remove

16
add 1
add 2
add 3
add 4
add 5
add 6
add 7
add 8
add 9
add 10
add 11
add 12
add 13
add 14
add 15
add 16
remove
remove
remove
remove
remove
remove
remove
remove
remove
remove
remove
remove
remove
remove
remove
remove

6
add 1
add 2
add 3
add 4
add 5
add 6
remove
remove
remove
remove
remove
remove

5
add 1
add 2
add 3
add 4
add 5
remove
remove
remove
remove
remove

4
add 2
add 1
remove
add 3
remove
add 4
remove
remove

5
add 3
add 2
add 1
remove
add 4
remove
remove
remove
add 5
remove

4
add 1
add 2
remove
remove
add 4
add 3
remove
remove

3
add 1
remove
add 2
add 3
remove
remove

3
add 2
add 1
remove
add 3
remove
remove

11
add 10
add 9
add 11
add 1
add 5
add 6
remove
add 3
add 8
add 2
add 4
remove
remove
remove
remove
remove
add 7
remove
remove
remove
remove
remove

15
add 12
add 7
add 10
add 11
add 5
add 2
add 1
add 6
add 8
remove
remove
add 15
add 4
add 13
add 9
add 3
add 14
remove
remove
remove
remove
remove
remove
remove
remove
remove
remove
remove
remove
remove

4
add 4
add 3
add 2
add 1
remove
remove
remove
remove

n = int(input())
cnt = 1
ans = 0
l = []
for i in range(2*n):
    a = input()
    if a[0] == 'a':
        l.append(int(a[4:]))
    else:
        if len(l) == 0:
            cnt += 1
        elif l[-1] == cnt:
            l.pop()
            cnt += 1
        else:
            l = []
            ans += 1
            cnt += 1
print(ans)


import java.util.*;
import java.io.*;

public class Main {

    static class Node implements Comparable<Node> {
        double power;
        double storage;
        double time;
        Node(double p, double s) {
            power = p;
            storage = s;
            time = s / p;
        }

        @Override
        public int compareTo(Node a) {
            return ((Double) this.time).compareTo(a.time);
        }
        public String toString() {
            return ((Double) time).toString();
        }
    }
    public static void main(String[] args) throws IOException {
        //BufferedReader in = new BufferedReader(new FileReader("input.in"));
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        //PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("output.out")));
        StringTokenizer st = new StringTokenizer(in.readLine());
        String s1 = st.nextToken();
        int total = 0;
        boolean add = false;
        boolean arr[] = new boolean[s1.length()];
        for (int i = 0; i < s1.length() - 1; i++) {
            if (s1.charAt(i) == 'V' && s1.charAt(i + 1) == 'K') {
                total++;
                arr[i] = true;
                arr[i+1] = true;
            }
        }
        for (int i = 1; i < s1.length(); i++) {
            if (s1.charAt(i) == 'K' && !arr[i - 1]) {
                add = true;
            }
        }
        for (int i = 0; i < s1.length() - 1; i++) {
            if (s1.charAt(i) == 'V' && !arr[i+1]) {
                add = true;
            }
        }
        out.println(total + (add ? 1 : 0));
        out.close();
        System.exit(0);
    }

    static class Pair implements Comparable<Pair> {
        int first;
        int second;

        public Pair(int first, int second) {
            this.first = first;
            this.second = second;
        }

        public int compareTo(Pair p) {
            if (first != p.first)
                return Integer.compare(first, p.first);
            return Integer.compare(second, p.second);
        }

        public int hashCode() {
            return first * 1_000_003 + second;
        }

        public boolean equals(Object o) {
            if (o == null || !(o instanceof Pair))
                return false;
            Pair p = (Pair) o;
            return first == p.first && second == p.second;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
int nxi() {
  int a;
  cin >> a;
  return a;
}
vector<long long> a;
void inc(int i, int v) {
  for (; i < a.size(); i |= i + 1) {
    a[i] += v;
  }
}
long long get(int r) {
  long long ans = 0;
  for (; r >= 0; r = (r & (r + 1)) - 1) {
    ans += a[r];
  }
  return ans;
}
long long get(int l, int r) { return get(r) - get(l - 1); }
int gcd(int a, int b) { return a == 0 ? b : gcd(b % a, a); }
long long phi(long long n) {
  long long result = n;
  for (long long i = 2; i * i <= n; ++i)
    if (n % i == 0) {
      while (n % i == 0) n /= i;
      result -= result / i;
    }
  if (n > 1) result -= result / n;
  return result;
}
int main() {
  long long n, k;
  cin >> n >> k;
  if (k % 2 == 0) --k;
  while (k > 1 && n > 1) {
    n = phi(n);
    k -= 2;
  }
  cout << (phi(n) % 1000000007);
  return 0;
}

mod=1e9+7

def Phi(n):
    phi=n
    i=2
    while i*i<= n:
        if n%i==0:
            while n%i==0:
                n//=i
            phi-=phi//i
        i+=1
    if n > 1:
        phi-=phi//n
    return phi

def f(n):
    return Phi(n)
def g(n):
    return n

n,k=map(int,input().split())

ans=n
k=(k+1)//2
while k!=0:
    ans=Phi(ans)
    if ans==1:
        break;
    k -=1
ans=int(ans%mod)
print(ans)


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;
public class Main
{
    static BufferedReader reader;
    static StringTokenizer tokenizer;
    static void init(InputStream input)
    {
        reader = new BufferedReader( new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
    static String next() throws IOException
    {
        while ( ! tokenizer.hasMoreTokens() )
        {
            tokenizer = new StringTokenizer(reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static long nextInt() throws IOException
    {
        return Long.parseLong( next() );
    }
    static PrintWriter writer;
    static void outit(OutputStream outputStream)
    {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }
    static void print(Object...objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    static void println(Object...objects) {
        print(objects);
        writer.println();
    }

    static void close() {
        writer.close();
    }

    static void flush() {
        writer.flush();
    }
    public static void main(String [] args) throws IOException
    {
        init(System.in) ;
        outit(System.out) ;
//    	int t = (int) nextInt() ;
//    	for(int i =0 ; i<t ; i++)
        output() ;
        flush();
        close();
    }
    public static int p(int i)
    {
    	return (int)Math.pow(2,i) ;
    }
    static int [][][] a ;
    static long  p ;
    static long [] tree ;
    static long [] x ;
    static long [] y ;
    static double pi = 3.14159 ;
    static double [] ang ;
    static char [][] board ;
    static boolean [][] spec ;
    static boolean [][] visited_a ;
    static boolean [][] visited_w ;
    static boolean check ;
    static double PI = 3.14159 ;
    public static final int MAXN = 1000 * 1001;
    static int n ;
    static int k ;
    static ArrayList<ArrayList<Integer>> ar ;
    static boolean [] visited ;
    public static void output() throws IOException
    {
    	n = (int)nextInt() ;
    	int k = (int)nextInt() ;
    	k = Math.min(k,n-k) ;
    	long [] BIT = new long[n+1] ;
    	Arrays.fill(BIT,0);
    	long ans = 1 ;
    	int start = 1 ;
    	int end = 1 ;
    	for(int i = 1 ; i<=n ; i++)
    	{
    		start = end ;
    		if(start+k>n)
    		{
    			end = start+k-n ;
    		}
    		else
    		{
    			end = start+k ;
    		}
    		updateBIT(BIT,start,1) ;
    		updateBIT(BIT,end,1) ;
    		int inter = split_q(BIT,start+1,end-1) ;
//    		println(start+" "+end) ;
//    		print_BIT(n,BIT) ;
//    		println("*"+inter) ;
    		ans+=inter+1 ;
    		print(ans+" ") ;
    	}
    	println() ;
    }
    static void print_BIT(int n,long [] BIT)
    {
    	for(int i = 1 ; i<=n ; i++)
    	{
    		print(query(BIT,i)-query(BIT,i-1)+" ") ;
    	}
    	println() ;
    }
    static int split_q(long [] BIT,int start, int end)
    {
    	if(start>end)
    	{
    		return q_u(BIT,start,n)+q_u(BIT,1,end) ;
    	}
    	else
    	{
    		return q_u(BIT,start,end) ;
    	}
    }
    static int q_u(long [] BIT,int x, int y)
    {
    	return query(BIT,y)-query(BIT,x-1) ;
    }
    static void updateBIT(long[] arr, int pos, int val)
    {
        int len = arr.length;
        for (; pos < len; pos |= (pos + 1))
            arr[pos] += val;
    }
    static int query(long[] arr, int pos)
    {
        int sum = 0;
        for (; pos >= 0; pos = (pos & (pos + 1)) - 1)
            sum += arr[pos];
        return sum;
    }
}

import sys

inf = (1 << 31) - 1

def solve():
    n, k = map(int, input().split())

    if k > n - k:
        k = n - k

    bit = BinaryIndexedTree([0]*n)

    s = 0
    res = 1
    ans = []

    for i in range(n):
        t = (s + k) % n

        if s < t:
            res += bit.get_sum(t) - bit.get_sum(s + 1) + 1
            ans.append(res)
        else:
            res += bit.get_sum(n) - bit.get_sum(s + 1)
            res += bit.get_sum(t) + 1
            ans.append(res)

        bit.add(s, 1)
        bit.add(t, 1)

        s = t

    print(*ans)

class BinaryIndexedTree:
    ''' 1-origin Binary Indexed Tree '''

    def __init__(self, a):
        self.n = len(a)
        self.bit = [0]*(self.n + 1)

        for i in range(1, self.n + 1):
            self.bit[i] += a[i - 1]

            if i + (i & (-i)) <= self.n:
                self.bit[i + (i & (-i))] += self.bit[i]

    def add(self, i, x):
        ''' a_i += x '''
        i += 1 # 0-origin -> 1-origin

        while i <= self.n:
            self.bit[i] += x
            i += i & (-i)

    def get_sum(self, r):
        ''' sum(a[0 .. r)) '''
        res = 0

        while r > 0:
            res += self.bit[r]
            r -= r & (-r)

        return res

if __name__ == '__main__':
    solve()


import java.util.Scanner;
import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;

public class Check2
{
	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

		short nextShort()
        {
            return Short.parseShort(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

	public static void main(String args[])
	{
		FastReader sc =new FastReader();
		int n=sc.nextInt();

		int ip[]=new int[n];

		for(int i=0;i<n;i++)
			ip[i]=sc.nextInt();

		int flag=0;
		int mod[]=new int[n];
		for(int i=0;i<n-1;i++)
		{
			if(ip[i]<0)
			{
				flag=1;
				break;
			}
			if(ip[i]%2==0)
			{
				ip[i]=0;
				mod[i]=1;
			}
			else
			{
				ip[i+1]-=1;
				mod[i+1]=1;
			}
		}
		if(flag==1 || ip[n-1]%2!=0)
			System.out.println("NO");
		else
			System.out.println("YES");
	}
}

 /*class a implements Comparable<a>
	{
		int val;
		String name;
		a(int val,String name)
		{
			this.val=val;
			this.name=name;
		}

		public int compareTo(a a1)
		{
			if(val==a1.val)
			{
				//if(name.length()==a1.name.length())
					return name.compareTo(a1.name);
				//else
					//return name.length()<a1.name.length()?-1:1;
			}
			else if(val<a1.val)
			return 1;
			else
			return -1;
		}

	}  */

YES YES NO NO YES NO NO YES NO NO YES YES NO YES NO NO YES YES NO NO NO YES NO YES NO YES YES YES NO YES NO YES NO YES NO YES YES YES YES NO NO NO YES NO NO YES YES NO YES YES NO NO YES YES YES NO YES YES YES NO YES YES

#include <bits/stdc++.h>
using namespace std;
void imprimirVector(vector<int> &v) {
  if (!v.empty()) {
    int p = v.size();
    cout << "[";
    for (int i = 0; i < (int)(p - 1); i++) cout << v[i] << ",";
    cout << v[p - 1] << "]" << endl;
  } else
    cout << "[]" << endl;
}
int main() {
  int N;
  cin >> N;
  vector<long long> pizzas(N);
  for (int i = 0; i < (int)(N); i++) cin >> pizzas[i];
  long long am = 0;
  bool can = true;
  for (int i = 0; i < (int)(N); i++) {
    if (pizzas[i] > 0)
      am += pizzas[i];
    else {
      can &= (am % 2 == 0);
    }
  }
  can &= (am % 2 == 0);
  if (can)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}


/*
 * Code Author: Akshay Miterani
 * DA-IICT
 */
import java.io.*;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;

public class MainA {

	static double eps=(double)1e-6;
	static int mod=(int)1e9+7;
	public static void main(String args[]){
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		//----------My Code----------
		int n=in.nextInt();
		long adder=(long)1e9;
		long sum=0;
		Long a[]=new Long[n];
		for(int i=0;i<n;i++){
			a[i]=in.nextLong()+adder;
			sum+=a[i];
		}
		Arrays.sort(a);
		long ans=a[0],val=Long.MAX_VALUE,currleft=0;
		for(int i=0;i<n;i++){
			long left=i;
			long right=n-i-1;
			long sumright=(sum-a[i])-right*a[i];
			long sumleft=a[i]*left-(currleft);
			long sumhere=sumleft+sumright;
			if(sumhere<val){
				val=sumhere;
				ans=a[i];
			}
			//System.out.println(a[i]+" "+(sumhere)+" "+currleft+" "+sum+" "+ans);
			currleft+=a[i];
			sum-=a[i];
		}
		System.out.println(ans-adder);
		out.close();
		//---------------The End------------------

	}
	static boolean check(int x,int y){
		return x>=1 && x<=8 && y>=1 && y<=8;
	}
	static long gcd(long x, long y)
	{
		long r=0, a, b;
		a = (x > y) ? x : y; // a is greater number
		b = (x < y) ? x : y; // b is smaller number
		r = b;
		while(a % b != 0)
		{
			r = a % b;
			a = b;
			b = r;
		}
		return r;
	}

	public static void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream inputstream) {
			reader = new BufferedReader(new InputStreamReader(inputstream));
			tokenizer = null;
		}

		public String nextLine(){
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine=reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = (1 << 20) + 10;
int n, m, a[maxn], dp[21][maxn];
char ch[maxn];
int main() {
  scanf("%d%d", &n, &m);
  memset(a, 0, sizeof(a));
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= n; ++i) {
    scanf("%s", ch);
    for (int j = 0; j < m; ++j) a[j + 1] = a[j + 1] * 2 + ch[j] - '0';
  }
  for (int i = 1; i <= m; ++i) dp[0][a[i]]++;
  for (int mask = 0; mask < 1 << n; ++mask) {
    for (int i = 0; i < n; ++i) dp[1][mask] += dp[0][mask ^ (1 << i)];
  }
  for (int k = 2; k <= n; ++k) {
    for (int mask = 0; mask < 1 << n; ++mask) {
      for (int i = 0; i < n; ++i) dp[k][mask] += dp[k - 1][mask ^ (1 << i)];
      dp[k][mask] = (dp[k][mask] + (k - 2 - n) * dp[k - 2][mask]) / k;
    }
  }
  int ans = 2e9;
  for (int mask = 0; mask < 1 << n; ++mask) {
    int nowans = 0;
    for (int i = 1; i <= n; ++i) nowans += dp[i][mask] * min(i, n - i);
    ans = min(ans, nowans);
  }
  cout << ans << endl;
}

// practice with rainboy
import java.io.*;
import java.util.*;

public class CF663E {
	static void fwht(long[] aa, int n) {
		for (int h = 0, b; (b = 1 << h) < n; h++)
			for (int i = 0; i < n; i += b * 2)
				for (int j = 0; j < b; j++) {
					int l = i + j, r = l + b;
					long u = aa[l], v = aa[r];
					aa[l] = u + v;
					aa[r] = u - v;
				}
	}
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int m = Integer.parseInt(st.nextToken());
		char[][] cc = new char[n][m];
		for (int i = 0; i < n; i++)
			br.readLine().getChars(0, m, cc[i], 0);
		int n_ = 1 << n;
		long[] aa = new long[n_];
		for (int j = 0; j < m; j++) {
			int x = 0;
			for (int i = 0; i < n; i++)
				x = x * 2 + cc[i][j] - '0';
			aa[x]++;
		}
		long[] bb = new long[n_];
		for (int h = 1; h < n_; h++)
			bb[h] = bb[h & h - 1] + 1;
		for (int h = 0; h < n_; h++)
			bb[h] = bb[n_ - 1 ^ h] = Math.min(bb[h], bb[n_ - 1 ^ h]);
		fwht(aa, n_);
		fwht(bb, n_);
		for (int h = 0; h < n_; h++)
			aa[h] *= bb[h];
		fwht(aa, n_);
		for (int h = 0; h < n_; h++)
			aa[h] /= n_;
		long ans = m * n;
		for (int h = 0; h < n_; h++)
			ans = Math.min(ans, aa[h]);
		System.out.println(ans);
	}
}


import io
import sys
import time
import random
#~ start = time.clock()
#~ test = '''2 2 1 1
#~ 1 2'''
#~ test = '''3 2 3 3
#~ 1 1
#~ 3 1
#~ 2 2'''
#~ test = '''3 2 3 2
#~ 1 1
#~ 3 1
#~ 2 2'''

#~ sys.stdin = io.StringIO(test)

r,c,n,k = map(int,input().split()) # row column number-of-violists
data = [ [0 for i in range(c)] for j in range(r) ]
#~ print(r,c,n,k)

for i in range(n):
   x,y = map(int,input().split()) # row column
   data[x-1][y-1] = 1

nviolists = [ [0 for i in range(c)] for j in range(r) ]

for r1 in range(r):
   count = 0
   for c1 in range(c):
      count += data[r1][c1]
      nviolists[r1][c1] = (nviolists[r1-1][c1] if r1>0 else 0) \
                        + count
      #~ print(r1,c1,nviolists[r1][c1],nviolists[r1][c1-1])
      #~ print(nviolists)

count = 0
for r1 in range(r):
   for r2 in range(r1,r):
      for c1 in range(c):
         for c2 in range(c1,c):
            # between (r1,c1) and (r2,c2)

            vcount = nviolists[r2][c2] \
                  - (nviolists[r1-1][c2] if r1>0 else 0) \
                  - (nviolists[r2][c1-1] if c1>0 else 0) \
                  + (nviolists[r1-1][c1-1] if r1*c1>0 else 0)
            if vcount>=k:
               #~ print( (r1,c1), (r2,c2) )
               count +=1

print(count)
#~ dur = time.clock()-start
#~ print("Time:",dur)

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * Created by Anton Berezin on 1/21/2017.
 */
public class Orkestra {
    public static void main(String[] args) throws Exception {
        try(BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))){
            String[] line = reader.readLine().split(" ");
            int r = Integer.parseInt(line[0]);
            int c = Integer.parseInt(line[1]);
            int n = Integer.parseInt(line[2]);
            int k = Integer.parseInt(line[3]);
            int[] altRow = new int[n];
            int[] altCol = new int[n];
            for(int i = 0; i<n;i++) {
                line = reader.readLine().split(" ");
                altRow[i] = Integer.parseInt(line[0]) - 1;
                altCol[i] = Integer.parseInt(line[1]) - 1;
            }
            int answer = 0;
            for(int rowStart = 0; rowStart < r; rowStart++) {
                for(int colStart = 0; colStart < c; colStart++) {
                    for(int rowEnd = rowStart; rowEnd < r; rowEnd++) {
                        for(int colEnd = colStart; colEnd < c; colEnd++) {
                            int cnt = 0;
                            for(int i = 0;  i< n; i++) {
                                if (altRow[i]>=rowStart && altRow[i]<=rowEnd && altCol[i]>=colStart && altCol[i]<= colEnd) {
                                    cnt++;
                                }
                            }
                            if(cnt>= k) {
                                answer++;
                            }
                        }
                    }
                }
            }
            System.out.println(answer);
        }
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
static	class pair{
		int ele;
		int index;
		pair(int ele,int index){
			this.ele=ele;
			this.index=index;
		}
	}
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here

		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++){
			a[i]=in.nextInt();
		}
		Arrays.sort(a);
		boolean visited[]=new boolean[n+1];
		visited[a[0]]=true;
		pair b[]=new pair[n];
		for(int i=0;i<n;i++){
			b[i]=new pair(0,0);
		}
		int k=0;
		for(int i=1;i<n;i++){
			visited[a[i]]=true;
			if(a[i]==a[i-1])
			{

				b[k].ele=a[i];
				b[k].index=i;
				k++;
			}

		}
		int c[]=new int[6001];
		int h=0;
		for(int i=1;i<=n;i++){

			if(visited[i]==false){
				c[h]=i;
				h++;
			}

		}
		for(int i=n+1;i<=6000;i++){
			c[h]=i;
			h++;
		}
		int j=0;
		int count=0;
		for(int i=0;i<k;i++){
		while(b[i].ele>=c[j]){
              j+=1;
			}
				count+=c[j]-b[i].ele;
			j+=1;

		}
		System.out.println(count);
	}
}


#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<int, int>> a;
vector<pair<int, int>> b;
int main() {
  cin >> n;
  int m, dem = 0;
  for (int i = 1; i <= n; i++) {
    cin >> m;
    a.push_back(make_pair(i, m));
  }
  for (int i = 0; i < n - 1; i++)
    for (int j = i + 1; j < n; j++)
      if (a[i].second > a[j].second || a[i].first > a[j].first)
        swap(a[i], a[j]);
  for (int i = 0; i < n; i++)
    if (a[i].second == a[i + 1].second) dem++;
  if (dem < 2)
    cout << "NO";
  else {
    cout << "YES" << endl;
    for (auto x : a) cout << x.first << " ";
    cout << endl;
    b = a;
    for (int i = 0; i < n; i++)
      if (a[i].second == a[i + 1].second) {
        swap(a[i], a[i + 1]);
        break;
      }
    for (auto x : a) cout << x.first << " ";
    cout << endl;
    for (int i = 0; i < n - 1; i++)
      if (b[i].second == b[i + 1].second) swap(b[i], b[i + 1]);
    for (auto x : b) cout << x.first << " ";
  }
  return 0;
}

n = int(input())
ar = [int(i) for i in input().split()]

new = sorted((ar[i],i+1) for i in range(n))
res = [new[i][1] for i in range(n)]
swap = []
for i in range(n-1):
  if new[i][0] == new[i+1][0]:
    swap.append((i,i+1))
    if len(swap) == 2:
      print("YES")
      print(" ".join(str(i) for i in res))
      for j,k in swap:
        res[j],res[k] = res[k],res[j]
        print(" ".join(str(i) for i in res))
      quit()
print("NO")


import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
	    Scanner s = new Scanner(System.in);
	    while(s.hasNext()) {
	    // A * pow(X, n)  = B
	        boolean ok = false;
	    int a = s.nextInt(), b = s.nextInt(), n = s.nextInt();
	    for(int x=-50000;x<=50000;x++){
	        if (a * Math.pow(x,n) == b){
	            System.out.println(x);
	            ok = true;
                break;
	        }
	    }
	    if(!ok) System.out.println("No solution");
	    }
	}

	int gcd(int a,int b){
	    return b == 0 ? a : gcd(b, a % b);
	}
}

import math
import sys
a,b,c=input().split(' ')
a=int(a); b=int(b); c=int(c)
for i in range( -abs(b), abs(b)+1):
    if a*pow(i, c)==b:
        print(i,end='')
        sys.exit(0)
print("No solution",end='')


import java.util.Scanner;

public class p9 {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		for(int i = k+1; i > 0; i--)
			System.out.printf("%d ", i);
		for(int i = k+2; i <= n; i++)
			System.out.printf("%d ", i);
	}

}

n,k = map(int,input().strip().split())
a=list(range(1,n+1))
a[:k+1] = a[k::-1]
a=[str(i) for i in a]
print(' '.join(a))


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class P_261A {
    static final FS sc = new FS();
    static final PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        int m = sc.nextInt();
        int[] q = sc.nextArray(m);
        int min = Integer.MAX_VALUE;
        for(int i=0; i<m; i++){
            min = Math.min(min, q[i]);
        }
        int n = sc.nextInt();
        ArrayList<Integer> a = new ArrayList<>();
        for(int i=0; i<n; i++){
            a.add(sc.nextInt());
        }
        Collections.sort(a, Collections.reverseOrder());
        int ans = 0;
        for(int i=0; i<n; i++){
//            for(int j=i, c=0; j<n && c<min; j++, c++){
//                ans += a.get(i);
//            }
            if(i%(min+2)<min) ans += a.get(i);
        }
        System.out.println(ans);
    }

    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception ignored) {
                }
            }
            return st.nextToken();
        }

        int[] nextArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextLong();
            }
            return a;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

#include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b) { return a > b; }
int main() {
  int n, m, a[100000], b[100000], min1, sum;
  while (scanf("%d", &n) != EOF) {
    min1 = 10000000, sum = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      if (a[i] < min1) min1 = a[i];
    }
    scanf("%d", &m);
    for (int i = 0; i < m; i++) scanf("%d", &b[i]);
    sort(b, b + m, cmp);
    for (int i = 0; i < m; i++) {
      if (i % (2 + min1) < min1) sum += b[i];
    }
    printf("%d\n", sum);
  }
  return 0;
}


from math import *

n, ans = int(input()), 0
if n < 3:
    ans = n
elif n % 2:
    ans = n * (n - 1) * (n - 2)
else:
    a = 0
    if gcd(n, n - 3) == 1:
        a = n * (n - 1) * (n - 3)
    n -= 1
    ans = max(n * (n - 1) * (n - 2), a)
print(ans)

import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author George Marcus
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		StreamInputReader in = new StreamInputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
	public void solve(int testNumber, StreamInputReader in, PrintWriter out) {
        int N = in.nextInt();
        if(N <= 2) {
            if(N == 1)
                out.print(1);
            if(N == 2)
                out.print(2);
            return;
        }

        long prod = (long)N * (N - 1);
        long max = prod;
        for(int i = 1; i < N - 1; i++)
            max = Math.max(max, lcm((long)i, prod));

        prod = (long)N * (N - 2) / gcd(N, N - 2);
        for(int i = 1; i < N; i++)
            max = Math.max(max, lcm((long)i, prod));

        prod = (long)(N - 1) * (N - 2) / gcd(N - 1, N - 2);
        for(int i = 1; i < N; i++)
            max = Math.max(max, lcm((long)i, prod));

        out.print(max);
	}

    private long lcm(long a, long b) {
        return a * b / gcd(a, b);
    }

    private long gcd(long a, long b) {
        long r = a % b;
        while(r > 0) {
            a = b;
            b = r;
            r = a % b;
        }
        return b;
    }
}

class StreamInputReader extends InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar, numChars;

    public StreamInputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    }

abstract class InputReader {

    public abstract int read();

    public int nextInt() {
        return Integer.parseInt(nextString());
    }

    public String nextString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    private boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    }


import java.io.*;
import java.util.*;

public class A implements Runnable {
	public static void main (String[] args) {new Thread(null, new A(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int n = fs.nextInt();
		int[] a = fs.nextIntArray(n);
		int[] b = fs.nextIntArray(n);
		int lo = 0, hi = n-1, res = n-1;
		for(int bs = 0; bs < 50 && lo <= hi; bs++) {
			int mid = (lo+hi)/2;
			int R = n-mid;
			int L = 0;
			for(int i = 0; i < n && L < R; i++) {
				if(b[i] == a[L]) L++;
			}
			if(L == R) {
				res = mid;
				hi = mid-1;
			}
			else {
				lo = mid+1;
			}
		}
		out.println(res);

		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}

	}

}

n = int(input())
l1 = [int(x) for x in input().split()]
l2 = [int(x) for x in input().split()]

used = set()
j = len(l1)-1
worst = j

for i in range(len(l2)-1, -1, -1):
    if l2[i] in used:
        continue
    if l2[i] == l1[j]:
        j-=1
    else:
        while l2[i] != l1[j]:
            used.add(l1[j])
            j-=1
        j -= 1
        worst = j+1
#print(worst)
print(len(l1) - worst - 1)


import java.util.*;
import java.io.*;
public class B{
	public static void main(String[] args)
	{
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int t = fs.nextInt();
		for(int tt=0;tt<t;tt++)
		{
			int n = fs.nextInt();
			int[] arr = fs.readArray(n);
			boolean flag = false;
			for(int i:arr)
			{
				int start = 0;
				while(start*start<i)start++;
				if(start*start != i)
				{
					flag = true;
					break;
				}
			}
			out.println(flag == true?"YES":"NO");
		}
		out.close();
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
	public static int[] sort(int[] arr)
	{
		List<Integer> temp = new ArrayList();
		for(int i:arr)temp.add(i);
		Collections.sort(temp);
		int start = 0;
		for(int i:temp)arr[start++]=i;
		return arr;
	}
}

import math
rr = input
rri = lambda: int(rr())
rrm = lambda: list(map(int, rr().split()))

def perfect_square(n):
    root = math.sqrt(n)
    if int(root + 0.5) ** 2 == n:
        return True
    else:
        return False

def prod(lst):
    ret = 1
    for i in lst:
        ret *= i
    return ret

def solve():
    n =  rri()
    lst = rrm()
    for i in lst:
        if not perfect_square(i):
            return "YES"
    #for i in range(n):
        #for j in range(i,n):
        #    print(i, j)
         #   if not perfect_square(prod(lst[i:j+1])):
          #      return 'YES'
    return 'NO'

T = rri()

for t in range(T):

    print(solve())