using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Globalization;

namespace Beresta
{

	class ContestIO : StreamWriter
	{
		public ContestIO(Stream streamIn, Stream streamOut) : base(streamOut, Encoding.ASCII, 8192) { Reader = new StreamReader(streamIn, Encoding.ASCII, false, 8192); }
		public ContestIO(string inputFilePath, string outputFilePath) : this(File.OpenRead(inputFilePath), File.OpenWrite(outputFilePath)) { }
		public ContestIO(string inputText) : this(new MemoryStream(Encoding.ASCII.GetBytes(inputText)), Console.OpenStandardOutput(8192)) { }
		public ContestIO() : this(Console.OpenStandardInput(8192), Console.OpenStandardOutput(8192)) { }
		//d.ToString("N12", CultureInfo.InvariantCulture).Replace(",", "")
		public StreamReader Reader;

		bool IsDigit(int c) { return c >= '0' && c <= '9'; }
		public long Read()
		{
			int c1 = 0, c;
			while (!IsDigit(c = Reader.Read())) { c1 = c; }
			long r = c - '0';
			while (IsDigit(c = Reader.Read()))
				r = r * 10 + c - '0';
			return c1 == '-' ? -r : r;
		}
		public long[] ReadArray(int size) { return Enumerable.Range(0, size).Select(v => Read()).ToArray(); }
	}

	class Friend : IComparer<Friend>
	{
		public long Id;
		public long Power;

		public int Compare(Friend x, Friend y)
		{
			return x.Power.CompareTo(y.Power);
		}
	}

	class Program
	{

		static void Main(string[] args)
		{
			using (var io = new ContestIO())
			{
				var n = io.Read();
				var k = io.Read();
				var q = io.Read();

				var arr = io.ReadArray((int)n);

				List<Friend> friends = new List<Friend>((int)n);
				for (var i = 0; i < n; i++)
				{
					friends.Add(new Friend()
					{
						Id = i,
						Power = arr[i]
					});
				}

				var heap = new BinaryHeap<Friend>(new Friend(), (int)k);
				var visible = new bool[n];

				for (var i = 0; i < q; i++)
				{
					var type = io.Read();
					var id = io.Read() - 1;

					if (type == 1)
					{
						heap.Add(friends[(int)id]);
						visible[id] = true;
						if (heap.Count > k)
						{
							var removed = heap.Pop();
							visible[removed.Id] = false;
						}
					}
					else
					{
						if (visible[id])
							io.WriteLine("YES");
						else
							io.WriteLine("NO");
					}
				}
			}

			Console.ReadLine();
		}

	}

	public class BinaryHeap<T>
	{
		class BinaryHeapComparer : IComparer<T>
		{
			public Func<T, T, int> Comparer;
			public int Compare(T x, T y)
			{
				return Comparer(x, y);
			}
		}

		public BinaryHeap(IComparer<T> comparer, int? capacity = null)
			: this(capacity)
		{
			this.comparer = comparer;
		}
		public BinaryHeap(Func<T, T, int> comparer, int? capacity = null)
			: this(capacity)
		{
			this.comparer = new BinaryHeapComparer()
			{
				Comparer = comparer
			};
		}
		BinaryHeap(int? capacity)
		{
			if (capacity.HasValue)
				items = new List<T>(capacity.Value);
			else
				items = new List<T>();
			items.Add(default(T));
		}

		IComparer<T> comparer;
		List<T> items;

		public int Count
		{
			get { return items.Count - 1; }
		}
		public T Min()
		{
			if (items.Count == 1)
				throw new Exception();
			return items[1];
		}
		void Swap(int p1, int p2)
		{
			var tmp = items[p1];
			items[p1] = items[p2];
			items[p2] = tmp;
		}
		public void Add(T item)
		{
			items.Add(item);
			int p = items.Count - 1;
			int p1 = p >> 1;
			while (p1 >= 1 && comparer.Compare(item, items[p1]) < 0)
			{
				Swap(p, p1);
				p = p1;
				p1 = p >> 1;
			}
		}
		public T Pop()
		{
			if (items.Count == 1)
				throw new Exception();
			var res = items[1];

			var mp = items.Count - 1;
			items[1] = items[mp];
			items.RemoveAt(mp);
			mp--;

			var p = 1;
			var p1 = 2;
			while (p1 <= mp)
			{
				var p2 = p1 + 1;
				var pmin = p2 > mp || comparer.Compare(items[p1], items[p2]) < 0 ? p1 : p2;
				if (comparer.Compare(items[pmin], items[p]) < 0)
				{
					Swap(p, pmin);
					p = pmin;
				}
				else
					break;
				p1 = p * 2;
			}

			return res;
		}
	}

}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _658B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split(' '), input2 = Console.ReadLine().Split(' ');
            int n = int.Parse(input1[0]), k = int.Parse(input1[1]), q = int.Parse(input1[2]);
            int[] t = new int[n];
            for (int i = 0; i < n; i++) t[i] = int.Parse(input2[i]);

            List<int> showing = new List<int>(k);
            List<bool> results = new List<bool>();
            for (int i = 0; i < q; i++)
            {
                string[] line = Console.ReadLine().Split(' ');
                int type = int.Parse(line[0]), id = int.Parse(line[1]) - 1;
                if (type == 1)
                {
                    if (showing.Count < k)
                    {
                        showing.Add(id);
                    }
                    else if (showing.Count == k)
                    {
                        int min = showing.Min(x => t[x]);
                        if (t[id] > min)
                        {
                            showing.RemoveAt(showing.FindIndex(x => t[x] == min));
                            showing.Add(id);
                        }
                    }
                }
                else
                {
                    results.Add(showing.Contains(id));
                }
            }

            foreach (var x in results)
            {
                Console.WriteLine(x ? "YES" : "NO");
            }
            //Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Codeforces
{
    class Program
    {

        static void Main(string[] args)
        {
            //#if DEBUG
            StreamReader reader = new StreamReader(Console.OpenStandardInput(32768), Encoding.ASCII, false, 32768);
            StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(32768), Encoding.ASCII, 32768);
            //#else
            //            StreamReader streamReader = new StreamReader(Console.OpenStandardInput(32768), Encoding.ASCII, false, 32768);
            //            StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(32768), Encoding.ASCII, 32768);
            //#endif
            InputReader input = new InputReader(reader);

            int n = input.NextInt();
            int k = input.NextInt();
            int q = input.NextInt();
            int[] t = input.NextIntArray(n);
            int op, id;
            SortedList<int, int> sl = new SortedList<int, int>();
            while (q-- > 0)
            {
                op = input.NextInt();
                id = input.NextInt() - 1;
                if (op == 1)
                {
                    sl.Add(t[id],0);
                }
                else
                {
                    int index = sl.IndexOfKey(t[id]);
                    if (index < 0 || !(index >= sl.Count - k))
                    {
                        writer.WriteLine("No");
                    }
                    else
                    {
                        writer.WriteLine("Yes");
                    }
                }
            }

#if DEBUG
                Console.BackgroundColor = ConsoleColor.White;
                Console.ForegroundColor = ConsoleColor.Black;
#endif
            writer.Close();
            reader.Close();
        }
    }

    // this class is copy
    class InputReader
    {
        private char[] _inbuf;
        private int _lenbuf = 0, _ptrbuf = 0;
        private StreamReader _reader;

        public InputReader(StreamReader reader)
        {
            _reader = reader;
            _inbuf = new char[1024];
            _lenbuf = 0;
            _ptrbuf = 0;
        }

        private int ReadByte()
        {
            if (_lenbuf == -1)
                throw new Exception();
            if (_ptrbuf >= _lenbuf)
            {
                _ptrbuf = 0;
                try
                {
                    _lenbuf = _reader.Read(_inbuf, 0, 1024);
                }
                catch (IOException e)
                {
                    throw e;
                }
                if (_lenbuf <= 0)
                    return -1;
            }
            return _inbuf[_ptrbuf++];
        }

        private bool IsSpaceChar(int c)
        {
            return !(c >= 33 && c <= 126);
        }

        private int Skip()
        {
            int b;
            while ((b = ReadByte()) != -1 && IsSpaceChar(b)) ;
            return b;
        }

        public int NextInt()
        {
            return int.Parse(this.Next());
        }

        public int[] NextIntArray(int n)
        {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = NextInt();
            }
            return a;
        }

        public long NextLong()
        {
            return long.Parse(this.Next());
        }

        public string Next()
        {
            var b = Skip();
            var sb = new StringBuilder();
            while (!(IsSpaceChar(b)))
            {
                sb.Append((char)b);
                b = ReadByte();
            }
            return sb.ToString();
        }

        public double NextDouble()
        {
            return double.Parse(Next(), CultureInfo.InvariantCulture);
        }

        internal long[] NextLongArray(long n)
        {
            long[] a = new long[(int)n];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = NextLong();
            }
            return a;
        }

        internal double[] NextDoubleArray(int n)
        {
            double[] a = new double[n];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = NextDouble();
            }
            return a;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Codeforces
{
    class Program
    {

        static void Main(string[] args)
        {
            //#if DEBUG
            StreamReader reader = new StreamReader(Console.OpenStandardInput(32768), Encoding.ASCII, false, 32768);
            StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(32768), Encoding.ASCII, 32768);
            //#else
            //            StreamReader streamReader = new StreamReader(Console.OpenStandardInput(32768), Encoding.ASCII, false, 32768);
            //            StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(32768), Encoding.ASCII, 32768);
            //#endif
            InputReader input = new InputReader(reader);

            int n = input.NextInt();
            int k = input.NextInt();
            int q = input.NextInt();
            int[] t = input.NextIntArray(n);
            int op, id;
            SortedList<int, int> sl = new SortedList<int, int>();
            while (q-- > 0)
            {
                op = input.NextInt();
                id = input.NextInt() - 1;
                if (op == 1)
                {
                    sl.Add(t[id],0);
                }
                else
                {
                    int index = sl.IndexOfKey(t[id]);
                    if (index < 0 || !(index >= sl.Count - k))
                    {
                        writer.WriteLine("NO");
                    }
                    else
                    {
                        writer.WriteLine("YES");
                    }
                }
            }

#if DEBUG
                Console.BackgroundColor = ConsoleColor.White;
                Console.ForegroundColor = ConsoleColor.Black;
#endif
            writer.Close();
            reader.Close();
        }
    }

    // this class is copy
    class InputReader
    {
        private char[] _inbuf;
        private int _lenbuf = 0, _ptrbuf = 0;
        private StreamReader _reader;

        public InputReader(StreamReader reader)
        {
            _reader = reader;
            _inbuf = new char[1024];
            _lenbuf = 0;
            _ptrbuf = 0;
        }

        private int ReadByte()
        {
            if (_lenbuf == -1)
                throw new Exception();
            if (_ptrbuf >= _lenbuf)
            {
                _ptrbuf = 0;
                try
                {
                    _lenbuf = _reader.Read(_inbuf, 0, 1024);
                }
                catch (IOException e)
                {
                    throw e;
                }
                if (_lenbuf <= 0)
                    return -1;
            }
            return _inbuf[_ptrbuf++];
        }

        private bool IsSpaceChar(int c)
        {
            return !(c >= 33 && c <= 126);
        }

        private int Skip()
        {
            int b;
            while ((b = ReadByte()) != -1 && IsSpaceChar(b)) ;
            return b;
        }

        public int NextInt()
        {
            return int.Parse(this.Next());
        }

        public int[] NextIntArray(int n)
        {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = NextInt();
            }
            return a;
        }

        public long NextLong()
        {
            return long.Parse(this.Next());
        }

        public string Next()
        {
            var b = Skip();
            var sb = new StringBuilder();
            while (!(IsSpaceChar(b)))
            {
                sb.Append((char)b);
                b = ReadByte();
            }
            return sb.ToString();
        }

        public double NextDouble()
        {
            return double.Parse(Next(), CultureInfo.InvariantCulture);
        }

        internal long[] NextLongArray(long n)
        {
            long[] a = new long[(int)n];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = NextLong();
            }
            return a;
        }

        internal double[] NextDoubleArray(int n)
        {
            double[] a = new double[n];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = NextDouble();
            }
            return a;
        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AlgoTraining.Codeforces.VkCup2016
{

    class FastScanner : StreamReader
    {
        private string[] _line;
        private int _iterator;

        public FastScanner(Stream stream) : base(stream)
        {
            _line = null;
            _iterator = 0;
        }
        public int NextInt()
        {
            if (_line == null || _iterator >= _line.Length)
            {
                _line = base.ReadLine().Split(' ');
                _iterator = 0;
            }
            if (_line.Count() == 0) throw new IndexOutOfRangeException("Input string is empty");
            return Convert.ToInt32(_line[_iterator++]);
        }
        public long NextLong()
        {
            if (_line == null || _iterator >= _line.Length)
            {
                _line = base.ReadLine().Split(' ');
                _iterator = 0;
            }
            if (_line.Count() == 0) throw new IndexOutOfRangeException("Input string is empty");
            return Convert.ToInt64(_line[_iterator++]);
        }
    }
    class BearAndDisplayedFriendsB
    {
        public static void Main(string[] args)
        {
            using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
            using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
            {
                int n = fs.NextInt(), k = fs.NextInt(), q = fs.NextInt();
                User[] t = new User[n];
                List<User> d = new List<User>(k);
                for (int i = 0; i < n; i++)
                {
                    t[i] = new User { Id = i, Val = fs.NextInt() };
                }
                while (q-- > 0)
                {
                    int type = fs.NextInt(), id = fs.NextInt() - 1;
                    if (type == 1)
                    {
                        if (d.Count < k) d.Add(t[id]);
                        else
                        {
                            d = d.OrderByDescending(el => el.Val).ToList();
                            if (d.Last().Val < t[id].Val)
                            {
                                d.RemoveAt(k - 1);
                                d.Add(t[id]);
                            }
                        }
                    }
                    else
                    {
                        writer.WriteLine(d.Contains(t[id]) ? "YES" : "NO");
                    }
                }
            }
        }
    }
    class User
    {
        public int Id, Val;
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;

namespace ConsoleApplication1
{
    class vccup2
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader(@"D:\Sergey\Code\2.txt"));

            string[] strParams = Console.ReadLine().Split(new char[] { ' ' });
            int n = int.Parse(strParams[0]);
            int k = int.Parse(strParams[1]);
            int q = int.Parse(strParams[2]);

            strParams = Console.ReadLine().Split(new char[] { ' ' });
            var t = new List<int>(n);
            for (int i = 0; i < n; i++)
            {
                t.Add(int.Parse(strParams[i]));
            }

            var ss = new SortedList<int, int>();
            for (int i = 0; i < q; i++)
            {
                strParams = Console.ReadLine().Split(new char[] { ' ' });
                int typeq = int.Parse(strParams[0]);
                int fid = int.Parse(strParams[1]) - 1;
                if (typeq == 1)
                {
                    ss[t[fid]] = fid;
                    if (ss.Count > k)
                    {
                        var e = ((IEnumerable<int>)ss.Keys).GetEnumerator();
                        e.MoveNext();
                        var firstKey = e.Current;
                        ss.Remove(firstKey);
                    }
                }
                else if (typeq == 2)
                {
                    if (ss.ContainsKey(t[fid]))
                    {
                        Console.WriteLine("YES");
                    }
                    else
                        Console.WriteLine("NO");

                }
            } // forq

        }//main
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;

namespace ConsoleApplication
{
	class Program
	{
		static void Main(string[] args)
		{
			string input = @"6 3 9
50 20 51 17 99 24
1 3
1 4
1 5
1 2
2 4
2 2
1 1
2 4
2 3";
			// StringReader sr = new StringReader(input);
			string str = Console.ReadLine();
			if (str != null)
			{
				string[] arrStr = str.Split(' ');
				long n = long.Parse(arrStr[0]);
				long k = long.Parse(arrStr[1]);
				long q = long.Parse(arrStr[2]);

				Dictionary<long, long> tArr = new Dictionary<long, long>((int)n);

				str = Console.ReadLine();
				if (str != null)
				{
					arrStr = str.Split(' ');
					for (int i = 0; i < n; i++)
					{
						tArr.Add(i+1, long.Parse(arrStr[i]));
					}
				}

				Dictionary<long, Tuple<long,long>> queries = new Dictionary<long, Tuple<long,long>>((int)q);
				for (int i = 0; i < q; i++)
				{
					str = Console.ReadLine();
					if (str != null)
					{
						arrStr = str.Split(' ');
						queries.Add(i, new Tuple<long, long>(long.Parse(arrStr[0]), long.Parse(arrStr[1])));
					}
				}

				long[] current = new long[k];

				// logic
				foreach (var query in queries)
				{
					if (query.Value.Item1 == 1)
					{
						for (int i = 0; i < k; i++)
						{
							if (query.Value.Item2 == current[i])
							{
								break;
							}

							if (current[i] == 0)
							{
								current[i] = query.Value.Item2;
								break;
							}

							if (tArr[query.Value.Item2] >= tArr[current[i]] && query.Value.Item2 != current[i])
							{
								long prev = current[i];
								for (int j = i; j < k - 1; j++)
								{
									long next = current[j + 1];
									current[j + 1] = prev;
									prev = next;
								}
								current[i] = query.Value.Item2;
								break;
							}
						}
					}

					if (query.Value.Item1 == 2)
					{
						Console.WriteLine(current.Contains(query.Value.Item2) ? "YES" : "NO");
					}
				}
			}
		}
	}
}


#include <stdio.h>
#include <stdlib.h>

typedef struct Bear {
    int active, relation;
} Bear;

Bear *pop(Bear **heap, int count);
void push(Bear **heap, int count, Bear *b);
void sift_up(Bear **heap, int start, int end);
void sift_down(Bear **heap, int start, int end);
void swap(Bear **heap, int a, int b);

/*
 * http://codeforces.com/contest/658/problem/B
 */
int main()
{
    int n = 0, k = 0, q = 0;
    scanf("%d%d%d", &n, &k, &q);

    Bear *t = calloc(n, sizeof(Bear));
    for (int i = 0; i < n; i++) {
        scanf("%d", &t[i].relation);
    }

    Bear **h = calloc(n, sizeof(Bear *));

    int c = 0, d = 0, hs = 0;
    for (int i = 0; i < q; i++) {
        scanf("%d%d", &c, &d);

        if (c == 1) {
            if (hs == k) {
                if (t[d - 1].relation > h[0]->relation) {
                    Bear *b = pop(h, hs--);
                    b->active = 0;
                    push(h, hs++, &t[d - 1]);
                    t[d - 1].active = 1;
                }
            } else {
                push(h, hs++, &t[d - 1]);
                t[d - 1].active = 1;
            }
        } else {
            if (t[d - 1].active) {
                printf("YES\n");
            } else {
                printf("NO\n");
            }
        }
    }
    return 0;
}

Bear *pop(Bear **heap, int count)
{
    Bear *root = heap[0];

    heap[0] = heap[count - 1];
    sift_down(heap, 0, count - 2);

    return root;
}

void sift_down(Bear **heap, int start, int end)
{
    int root = start, swap_index = start, child = start * 2 + 1;

    while (child <= end) {
        if (heap[swap_index]->relation > heap[child]->relation) {
            swap_index = child;
        }
        if (child + 1 <= end && heap[swap_index]->relation > heap[child + 1]->relation) {
            swap_index = child + 1;
        }
        if (root != swap_index) {
            swap(heap, root, swap_index);
            root = swap_index;
            child = root * 2 + 1;
        }
        else {
            break;
        }
    }
}

void push(Bear **heap, int count, Bear *b)
{
    heap[count] = b;
    sift_up(heap, 0, count);
}

void sift_up(Bear **heap, int start, int end)
{
    int child = end;

    while (child >= start) {
        int parent = (child - 1) / 2;
        if (heap[parent]->relation > heap[child]->relation) {
            swap(heap, parent, child);
            child = parent;
        }
        else {
            break;
        }
    }
}

void swap(Bear **heap, int a, int b)
{
    Bear *t = heap[a];

    heap[a] = heap[b];
    heap[b] = t;
}


#include <stdio.h>
#include <stdlib.h>

typedef struct Bear {
    int active, relation;
} Bear;

Bear *pop(Bear **heap, int count);
void push(Bear **heap, int count, Bear *b);
void sift_up(Bear **heap, int start, int end);
void sift_down(Bear **heap, int start, int end);
void swap(Bear **heap, int a, int b);

/*
 * http://codeforces.com/contest/658/problem/B
 */
int main()
{
    int n = 0, k = 0, q = 0;
    scanf("%d%d%d", &n, &k, &q);

    Bear *t = calloc(n, sizeof(Bear));
    for (int i = 0; i < n; i++) {
        scanf("%d", &t[i].relation);
    }

    Bear **h = calloc(n, sizeof(Bear *));

    int c = 0, d = 0, hs = 0;
    for (int i = 0; i < q; i++) {
        scanf("%d%d", &c, &d);

        if (c == 1) {
            if (hs == k) {
                Bear *b = pop(h, hs--);
                b->active = 0;
            }

            push(h, hs++, &t[d - 1]);
            t[d - 1].active = 1;
        } else {
            if (t[d - 1].active) {
                printf("YES\n");
            } else {
                printf("NO\n");
            }
        }
    }
    return 0;
}

Bear *pop(Bear **heap, int count)
{
    Bear *root = heap[0];

    heap[0] = heap[count - 1];
    sift_down(heap, 0, count - 2);

    return root;
}

void sift_down(Bear **heap, int start, int end)
{
    int root = start, swap_index = start, child = start * 2 + 1;

    while (child <= end) {
        if (heap[swap_index]->relation > heap[child]->relation) {
            swap_index = child;
        }
        if (child + 1 <= end && heap[swap_index]->relation > heap[child + 1]->relation) {
            swap_index = child + 1;
        }
        if (root != swap_index) {
            swap(heap, root, swap_index);
            root = swap_index;
            child = root * 2 + 1;
        }
        else {
            break;
        }
    }
}

void push(Bear **heap, int count, Bear *b)
{
    heap[count] = b;
    sift_up(heap, 0, count);
}

void sift_up(Bear **heap, int start, int end)
{
    int child = end;

    while (child >= start) {
        int parent = (child - 1) / 2;
        if (heap[parent]->relation > heap[child]->relation) {
            swap(heap, parent, child);
            child = parent;
        }
        else {
            break;
        }
    }
}

void swap(Bear **heap, int a, int b)
{
    Bear *t = heap[a];

    heap[a] = heap[b];
    heap[b] = t;
}


#include<stdio.h>
int arr[7];
int k;
#include<stdlib.h>
int cmp(const void*a,const void*b)
{
	return *(int *)a-*(int*)b;
}
void insert(int a)
{
arr[0]=a;
qsort(arr,k+1,4,cmp);
arr[0]=0;
}
int main()
{
arr[0]=0;
	int n,q;
	scanf("%d %d %d",&n,&k,&q);
	int t[n+1];
	int i;
	for(i=1;i<=n;i++)
		scanf("%d",&t[i]);
	int a,b,j,flag=0;
	for(i=1;i<=q;i++)
	{
		scanf("%d %d",&a,&b);
			if(a==1)
				insert(t[b]);
			else
				if(a==2)
				{
					for(j=1;j<=k;j++)
					{
						if(t[b]==arr[j])
						{flag=1;break;}}
		if(flag==1)
			printf("YES\n");
		else
			printf("NO\n");
		flag=0;
				}
	}
	return 0;
}


#include<stdio.h>
#include<limits.h>
int storage[25][22];
struct solve{
    int status;
    int value;
}arr[250000];
int main(){
int a,b,c,d,e,f,g;
int first=0;
scanf("%d%d%d",&a,&b,&c);
int i;int added=0;
for(i=0;i<a;i++){
scanf("%d",&arr[i+1].value);
}
for(i=0;i<c;i++){
int x,y;
scanf("%d%d",&x,&y);
if(x==2){
if(arr[y].status==1){
        printf("YES\n");
}
else{ printf("NO\n");
        }
}
if(x==1 && added!=b){
arr[y].status=1;
storage[first][0]=arr[y].value;
storage[first++][1]=y;
added++;
}
else if(x==1 && added==b){
int min=INT_MAX; int pos=0;
for(f=0;f<b;f++){
if(storage[f][0]<min){
    min=storage[f][0];
    pos=f;
}
}
if(arr[y].value>storage[pos][0]){
arr[storage[pos][1]].status=0;
storage[pos][0]=arr[y].value;
storage[pos][1]=y;
arr[y].status=1;
break;
}
}
}
}


#include<stdio.h>
#include<limits.h>
char storage[25000][200];
struct solve{
    int status;
    int value;
}arr[250000];
int compare(struct solve *a,struct solve *b){
return a->value-b->value;
}
int find_smallest(int size,int check){
 int i; int min=INT_MAX; int min_index=-1;
 for(i=1;i<=size;i++){
 if(arr[i].value<min && arr[i].status==1 && arr[i].value<check){
 min=arr[i].value;
 min_index=i;}
 }
 if(min_index==-1)
    return -1;
 return min_index;
}
int main(){
int a,b,c,d,e,f,g;
int prva=0,druga=0;
scanf("%d%d%d",&a,&b,&c);
int i;int added=0;
for(i=0;i<a;i++){
scanf("%d",&arr[i+1].value);
}
for(i=0;i<c;i++){
int x,y;
scanf("%d%d",&x,&y);
if(x==2){
if(arr[y].status==1){
        printf("YES\n");
}
else{ printf("NO\n");
        }
}
if(x==1 && added!=b){
if(arr[y].status==0)
added++;
arr[y].status=1;
}
else if(x==1 && added==b){
int removal=find_smallest(a,arr[y].value);
if(removal!=-1){
arr[removal].status=0;
arr[y].status=1;
}
}
}
}


#include<stdio.h>
#include<limits.h>
int storage[25][22];
struct solve{
    int status;
    int value;
}arr[250000];
int main(){
int a,b,c,d,e,f,g;
int first=0;
scanf("%d%d%d",&a,&b,&c);
int i;int added=0;
for(i=0;i<a;i++){
scanf("%d",&arr[i+1].value);
}
for(i=0;i<c;i++){
int x,y;
scanf("%d%d",&x,&y);
if(x==2){
if(arr[y].status==1){
        printf("YES\n");
}
else{ printf("NO\n");
        }
}
if(x==1 && added!=b){
arr[y].status=1;
storage[first][0]=arr[y].value;
storage[first++][1]=y;
added++;
}
else if(x==1 && added==b){
int min=INT_MAX;
for(f=0;f<b;f++){
if(storage[f][0]<min){
    min=storage[f][0];
}
}
for(f=0;f<b;f++){
if(storage[f][0]==min && arr[y].value>min){
arr[storage[f][1]].status=0;
storage[f][0]=arr[y].value;
storage[f][1]=y;
arr[y].status=1;
break;
}
}
}
}
}


#include<stdio.h>
#include<limits.h>
struct info{
int index;
int value;
}arr1[500];
struct solve{
    int status;
    int value;
}arr[250000];
int compare(struct info *a,struct info *b){
return a->value-b->value;
}
int main(){
int a,b,c,d,e,f,g;
int first=0;
scanf("%d%d%d",&a,&b,&c);
int i;int added=0;
for(i=0;i<a;i++){
scanf("%d",&arr[i+1].value);
}
for(i=0;i<c;i++){
int x,y;
scanf("%d%d",&x,&y);
if(x==2){
if(arr[y].status==1){
        printf("YES\n");
}
else{ printf("NO\n");
        }
}
if(x==1 && added!=b){
arr[y].status=1;
arr1[first].value=arr[y].value;
arr1[first++].index=y;
added++;
qsort(arr1,first,sizeof(struct info),compare);
}
else if(x==1 && added==b){
if(arr[y].value>arr1[0].value){
arr[arr1[0].index].status=0;
arr1[0].value=arr[y].value;
arr1[0].index=y;
arr[y].status=1;
qsort(arr1,first,sizeof(struct info),compare);
}
}
}
}


#include<stdio.h>
#include<limits.h>
int storage[1][2];
struct solve{
    int status;
    int value;
}arr[250000];
int main(){
storage[0][0]=INT_MAX;
int a,b,c,d,e,f,g;
int first=0;
scanf("%d%d%d",&a,&b,&c);
int i;int added=0;
for(i=0;i<a;i++){
scanf("%d",&arr[i+1].value);
}
for(i=0;i<c;i++){
int x,y;
scanf("%d%d",&x,&y);
if(x==2){
if(arr[y].status==1){
        printf("YES\n");
}
else{ printf("NO\n");
        }
}
if(x==1 && added!=b){
arr[y].status=1;
if(arr[y].value<storage[0][0]){
storage[0][0]=arr[y].value;
storage[0][1]=y;
}
added++;
}
else if(x==1 && added==b){
if(arr[y].value>storage[0][0]){
arr[storage[0][1]].status=0;
storage[0][0]=arr[y].value;
storage[0][1]=y;
arr[y].status=1;
}}
}
}


#include<stdio.h>
#include<limits.h>
struct solve{
    int status;
    int value;
}arr[250000];
int compare(struct solve *a,struct solve *b){
return a->value-b->value;
}
int find_smallest(int size){
 int i; int min=INT_MAX; int min_index;
 for(i=0;i<size;i++){
 if(arr[i].value<min && arr[i].status==1){
 min=arr[i].value;
 min_index=i;}
 }
 return min_index;
}
int main(){
int a,b,c,d,e,f,g;
scanf("%d%d%d",&a,&b,&c);
int i;int added=0;
for(i=0;i<a;i++){
scanf("%d",&arr[i+1].value);
}
for(i=0;i<c;i++){
int x,y;
scanf("%d%d",&x,&y);
if(x==2){
if(arr[y].status==1){
        printf("YES\n");
}
else printf("NO\n");
}
if(x==1 && added!=b){
arr[y].status=1;
added++;
}
else if(x==1 && added==b){
int removal=find_smallest(a);
arr[removal].status=0;
arr[y].status=1;
}
}
}


#include<stdio.h>
#include<limits.h>
struct solve{
    int status;
    int value;
}arr[250000];
int compare(struct solve *a,struct solve *b){
return a->value-b->value;
}
int find_smallest(int size){
 int i; int min=INT_MAX; int min_index;
 for(i=1;i<=size;i++){
 if(arr[i].value<min && arr[i].status==1){
 min=arr[i].value;
 min_index=i;}
 }
 return min_index;
}
int main(){
int a,b,c,d,e,f,g;
scanf("%d%d%d",&a,&b,&c);
int i;int added=0;
for(i=0;i<a;i++){
scanf("%d",&arr[i+1].value);
}
for(i=0;i<c;i++){
int x,y;
scanf("%d%d",&x,&y);
if(x==2){
if(arr[y].status==1){
        printf("YES\n");
}
else printf("NO\n");
}
if(x==1 && added!=b){
arr[y].status=1;
added++;
}
else if(x==1 && added==b){
int removal=find_smallest(a);
arr[removal].status=0;
arr[y].status=1;
}
}

}


#include<stdio.h>
#include<limits.h>
int storage[25][22];
struct solve{
    int status;
    int value;
}arr[250000];
int main(){
int a,b,c,d,e,f,g;
int first=0;
scanf("%d%d%d",&a,&b,&c);
int i;int added=0;
for(i=0;i<a;i++){
scanf("%d",&arr[i+1].value);
}
for(i=0;i<c;i++){
int x,y;
scanf("%d%d",&x,&y);
if(x==2){
if(arr[y].status==1){
        printf("YES\n");
}
else{ printf("NO\n");
        }
}
if(x==1 && added!=b){
arr[y].status=1;
storage[first][0]=arr[y].value;
storage[first++][1]=y;
added++;
}
else if(x==1 && added==b){
int min=INT_MAX; int pos=0;
for(f=0;f<b;f++){
if(storage[f][0]<min){
    min=storage[f][0];
    pos=f;
}
}
if(arr[y].value>storage[pos][0]){
arr[storage[pos][1]].status=0;
storage[pos][0]=arr[y].value;
storage[pos][1]=y;
arr[y].status=1;
}
}
}
}


#include<stdio.h>
#include<limits.h>
struct solve{
    int status;
    int value;
}arr[250000];
int compare(struct solve *a,struct solve *b){
return a->value-b->value;
}
int find_smallest(int size){
 int i; int min=INT_MAX; int min_index;
 for(i=1;i<=size;i++){
 if(arr[i].value<min && arr[i].status==1){
 min=arr[i].value;
 min_index=i;}
 }
 return min_index;
}
int main(){
int a,b,c,d,e,f,g;
scanf("%d%d%d",&a,&b,&c);
int i;int added=0;
for(i=0;i<a;i++){
scanf("%d",&arr[i+1].value);
}
for(i=0;i<c;i++){
int x,y;
scanf("%d%d",&x,&y);
if(x==2){
if(arr[y].status==1){
        printf("YES\n");
}
else printf("NO\n");
}
if(x==1 && added!=b){
if(arr[y].status==0)
added++;
arr[y].status=1;
}
else if(x==1 && added==b){
int removal=find_smallest(a);
arr[removal].status=0;
arr[y].status=1;
}
}

}


#include <stdio.h>

#define MAX 150005

int n, k, q, i, j, kontrol, type, yer, id, t[MAX], cvp[10];

void cikar ();

int main () {
	scanf("%d %d %d",&n ,&k ,&q);
	for(i = 0 ; i < n ; i++)
		scanf("%d",&t[i]);
	for(i = 0 ; i < q ; i++){
		scanf("%d %d",&type ,&id);
		if(type == 1){
			cvp[yer++] = id;
			if(yer > k){
				cikar();
			}
		}
		else{
			kontrol = 0;
			for(j = 0 ; j < yer ; j++)
				if(cvp[j] == id)
					kontrol = 1;
			if(kontrol)
				printf("YES\n");
			else
				printf("NO\n");
		}
	}
	return 0;
}

void cikar () {
	int i, mn = 1000000005, ind, a[10] = {0}, place = 0;
	for(i = 0 ; i < yer ; i++){
		if(t[cvp[i-1]] < mn){
			mn = t[cvp[i-1]];
			ind = i;
		}
	}
	for(i = 0 ; i < yer ; i ++){
		if(i != ind)
			a[place++] = cvp[i];
		cvp[i] = 0;
	}
	for(i = 0 ; i < 10 ; i++)
		cvp[i] = a[i];
	yer--;
	return;
}


#include <stdio.h>

#define MAX 150005

int n, k, q, i, j, kontrol, type, yer, id, t[MAX], cvp[10];

void cikar ();

int main () {
	scanf("%d %d %d",&n ,&k ,&q);
	for(i = 0 ; i < n ; i++)
		scanf("%d",&t[i]);
	for(i = 0 ; i < q ; i++){
		scanf("%d %d",&type ,&id);
		if(type == 1){
			cvp[yer++] = id;
			if(yer > k){
				cikar();
			}
		}
		else{
			kontrol = 0;
			for(j = 0 ; j < yer ; j++)
				if(cvp[j] == id)
					kontrol = 1;
			if(kontrol)
				printf("YES\n");
			else
				printf("NO\n");
		}
	}
	return 0;
}

void cikar () {
	int i, mn = 1000000005, ind, a[10] = {0}, place = 0;
	for(i = 0 ; i < yer ; i++){
		if(t[cvp[i]-1] < mn){
			mn = t[cvp[i]-1];
			ind = i;
		}
	}
	for(i = 0 ; i < yer ; i ++){
		if(i != ind)
			a[place++] = cvp[i];
		cvp[i] = 0;
	}
	for(i = 0 ; i < 10 ; i++)
		cvp[i] = a[i];
	yer--;
	return;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, k, q, type, number, i, sum = 0, min, temp, flag;
    scanf("%d%d%d", &n, &k, &q);
    int t[n][2], t1[k];
    for(i = 0; i < n; i++)
    {
        scanf("%d", &t[i][0]);
        t[i][1] = 0;
    }
    while(q--)
    {
        scanf("%d%d", &type, &number);
        if(type == 1)
        {
            if(sum < k)
            {
                t[number-1][1] = 1;
                t1[sum] = number - 1;
                sum++;
            }
            else
            {
                flag = 0;
                min = number - 1;
                for(i = 0; i < k; i++)
                {
                    if(t[t1[i]][0] < t[min][0])
                    {
                        flag = 1;
                        temp = i;
                        min = t1[i];
                    }
                }
                if(flag == 1)
                    t1[temp] = number - 1;
                t[number-1][1] = 1;
                t[min][1] = 0;
            }
        }
        else
        {
            if(t[number-1][1] == 1)
                printf("YES\n");
            else
                printf("NO\n");
        }
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, k, q, type, number, i, sum = 0, min, temp;
    scanf("%d%d%d", &n, &k, &q);
    int t[n][2], t1[k];
    for(i = 0; i < n; i++)
    {
        scanf("%d", &t[i][0]);
        t[i][1] = 0;
    }

    while(q--)
    {
        scanf("%d%d", &type, &number);
        if(type == 1)
        {
            if(sum < k)
            {
                t[number-1][1] = 1;
                sum++;
            }
            else
            {
                min = number - 1;
                for(i = 0; i < n; i++)
                {
                    if(t[i][1] == 1)
                        if(t[i][0] < t[min][0])
                            min = i;
                }
                t[number-1][1] = 1;
                t[min][1] = 0;
            }
        }
        else
        {
            if(t[number-1][1] == 1)
                printf("YES\n");
            else
                printf("NO\n");
        }
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, k, q, type, number, i, sum = 0, min, temp;
    scanf("%d%d%d", &n, &k, &q);
    int t[n][2], t1[k];
    for(i = 0; i < n; i++)
    {
        scanf("%d", &t[i][0]);
        t[i][1] = 0;
    }
    while(q--)
    {
        scanf("%d%d", &type, &number);
        if(type == 1)
        {
            if(sum < k)
            {
                t[number-1][1] = 1;
                t1[sum] = number - 1;
                sum++;
            }
            else
            {
                min = number - 1;
                for(i = 0; i < k; i++)
                {
                    if(t[t1[i]][0] < t[min][0])
                    {
                        temp = i;
                        min = t1[i];
                    }
                }
                t1[temp] = number - 1;
                t[number-1][1] = 1;
                t[min][1] = 0;
            }
        }
        else
        {
            if(t[number-1][1] == 1)
                printf("YES\n");
            else
                printf("NO\n");
        }
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, k, q, type, number, i, sum = 0, min, temp, flag;
    scanf("%d%d%d", &n, &k, &q);
    int t[n][2], t1[k];
    for(i = 0; i < n; i++)
    {
        scanf("%d", &t[i][0]);
        t[i][1] = 0;
    }
    while(q--)
    {
        scanf("%d%d", &type, &number);
        if(type == 1)
        {
            if(sum < k)
            {
                t[number-1][1] = 1;
                t1[sum] = number - 1;
                sum++;
            }
            else
            {
                flag = 0;
                min = number - 1;
                for(i = 0; i < k; i++)
                {
                    if(t[t1[i]][0] < t[min][0])
                    {
                        flag = 1;
                        temp = i;
                        min = t1[i];
                    }
                }
                if(flag = 1)
                    t1[temp] = number - 1;
                t[number-1][1] = 1;
                t[min][1] = 0;
            }
        }
        else
        {
            if(t[number-1][1] == 1)
                printf("YES\n");
            else
                printf("NO\n");
        }
    }
    return 0;
}


#include<stdio.h>

int main()
{
    int a,b,e,n;
    int i,j,k,l;
    scanf("%d %d %d",&n,&a,&b);
    //int fr[150001];
    int val[150001];
    //int max[150001];
    int check[7]={0};
    int temp,temp1;
    int max=0;
    for(i=1;i<=n;i++)
    {
        scanf("%d",&val[i]);
        if(val[i]>max){max=val[i];}
    }
    int c,d,j1;
    k=1;
    int flag,min;
    for(i=1;i<=b;i++)
    {
        flag=0;
        scanf("%d %d",&c,&d);
        if(c==1)
        {
            min=max;
            for(j=1;j<=a;j++)
            {
                if(check[j]<min){min=check[j]; j1=j;}
            }
            if(min==0){check[k]=val[d];k++;}
            else if(val[d]>min){check[j1]=val[d];}
        }
        if(c==2)
        {
            for(j=1;j<=a;j++)
            {
                if(check[j]==val[d]){flag=1;}
            }
            if(flag==1){printf("YES\n");}
            else printf("NO\n");
        }

    }

return 0;
}


#include<stdio.h>
#include<stdlib.h>
long long int hash[150090] = {0};
long long int dis[2][150000];
main(){
	long long int n,k,q,*Fr_scr,op,id,len,i;
	scanf("%I64d %I64d %I64d",&n,&k,&q);
	len = 0;
	Fr_scr = (long long int *)malloc((n+1)*sizeof(long long int));

	//hash   = (long long int *)malloc((n+1)*sizeof(long long int));
	for(i = 1 ; i <= n ;i++)
		scanf("%I64d",&Fr_scr[i]);
	while(q--){
		scanf("%I64d %I64d",&op,&id);
		if(op == 1){
				if(len < k){
					dis[0][len] = Fr_scr[id];
					dis[1][len] = id;
					hash[id] = 1;
					len++;
				}
				else{
					long long int min = dis[0][0];
					long long int p = 0;
					long long int min_id = 0;
					for(i = 0 ; i < k ; i++){
						if(min > dis[0][i]){
							min = dis[0][i];
							p = i;
						}
					}
					if(min < Fr_scr[id]){
					min_id               = dis[1][p];
					dis[0][p]            = Fr_scr[id];
					dis[1][p]            = id;
					hash[id]             = 1;
					hash[min_id]         = 0;
				    }
				}
				//for(i = 0 ; i < k ; i++)
				//	printf("%d ",dis[i]);
		}
		if(op == 2){
			if(hash[id] == 1)
				printf("YES\n");
			if(hash[id] == 0)
				printf("NO\n");
		}
	}

}


#include<stdio.h>
#include<stdlib.h>
long long int hash[100000] = {0};
main(){
	long long int n,k,q,*Fr_scr,*dis,op,id,len,i;
	scanf("%I64d %I64d %I64d",&n,&k,&q);
	len = 0;
	Fr_scr = (long long int *)malloc((n+1)*sizeof(long long int));
	dis    = (long long int *)malloc((k+5)*sizeof(long long int));
	//hash   = (long long int *)malloc((n+1)*sizeof(long long int));
	for(i = 1 ; i <= n ;i++)
		scanf("%I64d",&Fr_scr[i]);
	while(q--){
		scanf("%I64d %I64d",&op,&id);
		if(op == 1){
				if(len < k){
					dis[len++] = Fr_scr[id];
					hash[Fr_scr[id]] = 1;
				}
				else{
					long long int min = dis[0];
					long long int p = 0;
					for(i = 0 ; i < k ; i++){
						if(min > dis[i]){
							min = dis[i];
							p = i;
						}
					}
					if(min < Fr_scr[id]){
					long long int tmp  = dis[p];
					dis[p]               = Fr_scr[id];
					hash[Fr_scr[id]]     = 1;
					hash[tmp]            = 0;
				    }
				}
				//for(i = 0 ; i < k ; i++)
				//	printf("%d ",dis[i]);
		}
		if(op == 2){
			if(hash[Fr_scr[id]] == 1)
				printf("YES\n");
			if(hash[Fr_scr[id]] == 0)
				printf("NO\n");
		}
	}

}


#include<stdio.h>
#include<stdlib.h>
int hash[100000] = {0};
main(){
	int n,k,q,*Fr_scr,*dis,op,id,len,i;
	scanf("%d %d %d",&n,&k,&q);
	len = 0;
	Fr_scr = (int *)malloc((n+1)*sizeof(int));
	dis    = (int *)malloc((k+5)*sizeof(int));
	//hash   = (int *)malloc((n+1)*sizeof(int));
	for(i = 1 ; i <= n ;i++)
		scanf("%d",&Fr_scr[i]);
	while(q--){
		scanf("%d %d",&op,&id);
		if(op == 1){
				if(len < k){
					dis[len++] = Fr_scr[id];
					hash[Fr_scr[id]] = 1;
				}
				else{
					int min = dis[0];
					int p = 0;
					for(i = 0 ; i < k ; i++){
						if(min > dis[i]){
							min = dis[i];
							p = i;
						}
					}
					if(min < Fr_scr[id]){
					int tmp              = dis[p];
					dis[p]               = Fr_scr[id];
					hash[Fr_scr[id]]     = 1;
					hash[tmp]            = 0;
				    }
				}
				//for(i = 0 ; i < k ; i++)
				//	printf("%d ",dis[i]);
		}
		if(op == 2){
			if(hash[Fr_scr[id]] == 1)
				printf("YES\n");
			if(hash[Fr_scr[id]] == 0)
				printf("NO\n");
		}
	}

}


#include <iostream>

using namespace std;

void nightWatch(){
    int numOfNums;
    cin>>numOfNums;
    int nums[numOfNums];
    int numOfFeeds = numOfFeeds= numOfNums -2;
    for (int i =0 ;i<numOfNums;i++)
    {
        cin>>nums[i];
    }
    if( numOfNums <=2)
    {
        cout<<0<<endl;
    }
    else {
        for(int i=0; i<numOfNums; i++)
    {
        for(int j=i+1; j<numOfNums; j++)
        {

            if(nums[j] < nums[i])
            {
                int temp = nums[i];
                nums[i] = nums[j];
                nums[j] = temp;
            }
        }

    }
    for (int i =1 ; i< numOfNums-1 ;i++)
    {
        if (nums[i]==nums[0]||nums[i]==nums[numOfNums-1])
        {
            numOfFeeds--;
        }
    }
    cout<<numOfFeeds<<endl;
}

}

void watch(){
    int numOfNums;
    cin>>numOfNums;
    int nums[numOfNums];
    int result=0;
    for(int i =0 ; i<numOfNums;i++)
    {

        cin>>nums[i];
    }
    if (numOfNums<=2)
    {
        cout<<0<<endl;
    }
    else {
            for (int i=1; i<numOfNums;i++)
            {
                if(nums[i]>nums[0] &&nums[i]<nums[numOfNums-1])
                {
                    result++;
                }

            }

            cout<<result<<endl;
    }

}

int main()
{
   watch();
    return 0;
}


#include <iostream>

using namespace std;

void nightWatch(){
    int numOfNums;
    cin>>numOfNums;
    int nums[numOfNums];
    int numOfFeeds = numOfFeeds= numOfNums -2;
    for (int i =0 ;i<numOfNums;i++)
    {
        cin>>nums[i];
    }
    if( numOfNums ==2)
    {
        cout<<numOfFeeds<<endl;
    }
    else {
        for(int i=0; i<numOfNums; i++)
    {
        for(int j=i+1; j<numOfNums; j++)
        {

            if(nums[j] < nums[i])
            {
                int temp = nums[i];
                nums[i] = nums[j];
                nums[j] = temp;
            }
        }

    }
    for (int i =1 ; i< numOfNums-1 ;i++)
    {
        if (nums[i]==nums[0]||nums[i]==nums[numOfNums-1])
        {
            numOfFeeds--;
        }
    }
    cout<<numOfFeeds<<endl;
}

}

int main()
{
   nightWatch();
    return 0;
}


#include <iostream>

using namespace std;

void watch(){
    long int numOfNums;
    cin>>numOfNums;
    long int nums[numOfNums];
    long int result=0;
    for(long int i =0 ; i<numOfNums;i++)
    {
        cin>>nums[i];
    }
    if (numOfNums<=2)
    {
        cout<<0<<endl;
    }
    else {

            for(int i=0; i<numOfNums; i++)
    {
        for(int j=i+1; j<numOfNums; j++)
        {
            //If there is a smaller element found on right of the array then swap it.
            if(nums[j] < nums[i])
            {
                int temp = nums[i];
                nums[i] = nums[j];
                nums[j] = temp;
            }
        }
    }

            for (long int i=1; i<numOfNums;i++)
            {
                if(nums[i]>nums[0] &&nums[i]<nums[numOfNums-1])
                {
                    result++;
                }
            }
            cout<<result<<endl;
    }
}

int main()
{
   watch();
    return 0;
}


#include <iostream>

using namespace std;

void nightWatch(){
    int numOfNums;
    cin>>numOfNums;
    int nums[numOfNums];
    int numOfFeeds = numOfFeeds= numOfNums -2;
    for (int i =0 ;i<numOfNums;i++)
    {
        cin>>nums[i];
    }
    if( numOfNums <=2)
    {
        cout<<0<<endl;
    }
    else {
        for(int i=0; i<numOfNums; i++)
    {
        for(int j=i+1; j<numOfNums; j++)
        {

            if(nums[j] < nums[i])
            {
                int temp = nums[i];
                nums[i] = nums[j];
                nums[j] = temp;
            }
        }

    }
    for (int i =1 ; i< numOfNums-1 ;i++)
    {
        if (nums[i]==nums[0]||nums[i]==nums[numOfNums-1])
        {
            numOfFeeds--;
        }
    }
    cout<<numOfFeeds<<endl;
}

}

int main()
{
   nightWatch();
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

void watch(){
    int numOfNums;
    cin>>numOfNums;
    int nums[numOfNums];
   int result=0;
    for(long int i =0 ; i<numOfNums;i++)
    {
        cin>>nums[i];
    }
    if (numOfNums<=2)
    {
        cout<<0<<endl;
    }
    else {

            sort(nums,nums+numOfNums);

            for ( int i=1; i<numOfNums;i++)
            {
                if(nums[i]>nums[0] &&nums[i]<nums[numOfNums-1])
                {
                    result++;
                }
            }
            cout<<result<<endl;
    }
}

int main()
{
   watch();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=0,i,j;
    cin>>n;
    int a[n];
    sort(a,a+n);

    for( j=0;j<n;j++)
        cin>>a[j];
         for( i=1;i<n-1;i++)
         {
             if(a[i]!= a[i+1])
             {
                 x++;
             }
         }

         cout<<x<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=0,i,j,s;
    cin>>n;
    int a[n];

    for( j=0;j<n;j++)
        cin>>a[j];

     sort(a,a+n);
         for( i=1;i<n;i++)
         {
          if(a[i]>a[0]&&a[i]<a[i+1])
          {
              x++;
          }
         }

         cout<<x<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=0,i,j;
    cin>>n;
    int a[n];

    for( j=1;j<n-1;j++)
        cin>>a[j];

     sort(a,a+n);
         for( i=0;i<n-1;i++)
         {
             if(a[i]!= a[i+1])
             {
                 x++;
             }
         }

         cout<<x<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=0,i,j,mn,mx;
    cin>>n;
    int a[n];

    for( j=0;j<n;j++)
        cin>>a[j];

     sort(a,a+n);
         mn = mx = a[0] ;
             for(int z=0 ; z<n ; z++)
    {
        mn = min(mn,a[z]);
        mx = max(mx,a[z]);
    }
         for( i=0;i<n;i++)
         {
            if(a[i] > mn && a[i]<mx)
          {
              x++;
          }
         }

         cout<<x<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=0,i,j;
    cin>>n;
    int a[n];
    sort(a,a+n);

    for( j=0;j<n;j++)
        cin>>a[j];
         for( i=1;i<n;i++)
         {
             if(a[i]!= a[i+1])
             {
                 x++;
             }
         }
         x--;
         cout<<x<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=0,i,j;
    cin>>n;
    int a[n];

    for( j=0;j<n;j++)
        cin>>a[j];

     sort(a,a+n);
         for( i=0;i<n-1;i++)
         {
             if(a[i]!= a[i+1])
             {
                 x++;
             }
         }

         cout<<x<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=0,i,j,s;
    cin>>n;
    int a[n];

    for( j=0;j<n;j++)
        cin>>a[j];

     sort(a,a+n);
         for( i=1;i<n;i++)
         {
          s+=a[i]>a[0]&&a[i]<a[n-1];
         }

         cout<<s<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=0,i,j;
    cin>>n;
    int a[n];

    for( j=0;j<n;j++)
        cin>>a[j];

     sort(a,a+n);
         for( i=1;i<n;i++)
         {
             if(a[i]!= a[i+1])
             {
                 x++;
             }
         }

         cout<<x<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=0,i,j;
    cin>>n;
    int a[n];

    for( j=0;j<n;j++)
        cin>>a[j];
     sort(a,a+n);
         for( i=1;i<n-1;i++)
         {
             if(a[i]!= a[i+1])
             {
                 x++;
             }
         }

         cout<<x<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=0,i,j,s;
    cin>>n;
    int a[n];

    for( j=0;j<n;j++)
        cin>>a[j];

     sort(a,a+n);
         for( i=1;i<n;i++)
         {
          s+=a[i]>a[0]&&a[i]<a[i+1];
         }

         cout<<s<<endl;
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int a , sumo=0;
	cin >> a;
	int x[a] , z[a];
	for(int i=0 ; i<a ; i++)
	{
		cin >> x[i];
	}
	for(int i=0 ; i<a ; i++)
	{
		int sum=0 , sum2=0;
		for(int j=0 ; j<a ; j++)
		{
			if(x[i]>x[j])
			{
				sum++;
				if(sum2>0)
				break;
			}
			if(x[i]>x[j])
			{
				sum2++;
				if(sum>0)
				break;
			}
		}
		if(sum>0 && sum2>0)
		sumo++;
	}
	cout<<sumo-1;
}


#include <iostream>
using namespace std;
int main()
{
	int a , sum=0 , sum2=0 , sumo=0;
	cin >> a;
	int x[a] , z[a];
	for(int i=0 ; i<a ; i++)
	{
		cin >> x[i];
	}
	for(int i=1 ; i<a-1 ; i++)
	{
		for(int j=0 ; j<a ; j++)
		{
			if(x[i]>x[j])
			{
				sum++;
				if(sum2>0)
				break;
			}
			if(x[i]>x[j])
			{
				sum2++;
				if(sum>0)
				break;
			}
		}
		if(sum>0 && sum2>0)
		sumo++;
	}
	cout<<sumo;
}


#include <bits/stdc++.h>
using namespace std;
set <long long> s;
int main(){
	long long a , maxi=-85 , mini=10e5;
	cin >> a;
	long long x[a];
	for(long long i=0 ; i<a ; i++){
		cin >> x[i];
		maxi=max(maxi , x[i]);
		mini=min(mini , x[i]);
	}
	long long sum=0;
	for(long long i=0 ; i<a ; i++){
		if(x[i]==mini || x[i]==maxi)
		sum++;
	}
	cout<<a-sum;
}


#include <iostream>
using namespace std;
int main()
{
	int a , sum=0 , sum2=0 , sumo=0;
	cin >> a;
	int x[a] , z[a];
	for(int i=0 ; i<a ; i++)
	{
		cin >> x[i];
	}
	for(int i=1 ; i<a-1 ; i++)
	{
		for(int j=0 ; j<a ; j++)
		{
			if(x[i]>x[j])
			sum++;
			if(x[i]>x[j])
			sum2++;
		}
		if(sum>0 && sum2>0)
		sumo++;
	}
	cout<<sumo;
}


#include <iostream>
using namespace std;
int main()
{
	int a , sum=0 , sum2=0 , sumo=0;
	cin >> a;
	int x[a] , z[a];
	for(int i=0 ; i<a ; i++)
	{
		cin >> x[i];
	}
	for(int i=1 ; i<a-1 ; i++)
	{
		for(int j=0 ; j<a ; j++)
		{
			if(x[i]>x[j])
			{
				sum++;
				if(sum2>0)
				break;
			}
			if(x[i]>x[j])
			{
				sum2++;
				if(sum>0)
				break;
			}
		}
		if(sum>0 && sum2>0)
		sumo++;
		sum=0;
		sum2=0;
	}
	cout<<sumo;
}


#include <iostream>
using namespace std;
int main()
{
	int a , sumo=0;
	cin >> a;
	int x[a] , z[a];
	for(int i=0 ; i<a ; i++)
	{
		cin >> x[i];
	}
	for(int i=1 ; i<a-1 ; i++)
	{
		int sum=0 , sum2=0;
		for(int j=0 ; j<a ; j++)
		{
			if(x[i]>x[j])
			{
				sum++;
				if(sum2>0)
				break;
			}
			if(x[i]>x[j])
			{
				sum2++;
				if(sum>0)
				break;
			}
		}
		if(sum>0 && sum2>0)
		sumo++;
	}
	cout<<sumo;
}


#include <bits/stdc++.h>
using namespace std;
set <int> s;
int main(){
	int a;
	cin >> a;
	int x[a];
	for(int i=0 ; i<a ; i++){
		cin >> x[i];
		s.insert(x[i]);
	}
	cout<<s.size()-2;
}


#include <bits/stdc++.h>
using namespace std;
set <long long> s;
int main(){
	long long a , maxi=-85 , mini=10e10;
	cin >> a;
	long long x[a];
	for(long long i=0 ; i<a ; i++){
		cin >> x[i];
		maxi=max(maxi , x[i]);
		mini=min(mini , x[i]);
	}
	long long sum=0;
	for(long long i=0 ; i<a ; i++){
		if(x[i]==mini || x[i]==maxi)
		sum++;
	}
	cout<<a-sum;
}


#include <bits/stdc++.h>
using namespace std;
set <long long> s;
int main(){
	long long a;
	cin >> a;
	long long x[a];
	for(long long i=0 ; i<a ; i++){
		cin >> x[i];
		s.insert(x[i]);
	}
	cout<<s.size()-2;
}


#include <iostream>
using namespace std;
int main()
{
	long long a , sumo=0;
	cin >> a;
	long long x[a] , z[a];
	for(long long i=0 ; i<a ; i++)
	{
		cin >> x[i];
	}
	for(long long i=0 ; i<a ; i++)
	{
		long long sum=0 , sum2=0;
		for(long long j=0 ; j<a ; j++)
		{
			if(x[i]>x[j])
			{
				sum++;
				if(sum2>0)
				break;
			}
			if(x[i]>x[j])
			{
				sum2++;
				if(sum>0)
				break;
			}
		}
		if(sum>0 && sum2>0)
		sumo++;
	}
	cout<<sumo-1;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n,l,count=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        if(n==1 || n==2)
        cout<<"0";
        else if(a[i]>a[i-1] && a[i]<a[i+1])
        count++;
    }
    cout<<count;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n,l,count=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    l=a.size();
    sort(a,a+l);
    for(int i=0;i<n;i++)
    {
        if(a[i]>a[i-1] && a[i]<a[i+1])
        count++;
    }
    cout<<count;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n,l,count=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        {
        if(n==1 || n==2)
        cout<<"0";
        break;
    }
        else if(a[i]>a[i-1] && a[i]<a[i+1])
        count++;
    }
    cout<<count;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n,l,count=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        if(a[i]>a[i-1] && a[i]<a[i+1])
        count++;
    }
    cout<<count;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n,l,count=0;
    cin>>n;
    int a[100000];
    for(int i=0;i<n;i++)
    cin>>a[i];
    l=a.size();
    sort(a,a+l);
    for(int i=0;i<n;i++)
    {
        if(a[i]>a[i-1] && a[i]<a[i+1])
        count++;
    }
    cout<<count;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n,l,count=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    for(int i=1;i<n-1;i++)
    {
        if(n==1 || n==2)
        {
        count=0;
        break;
    }
        else if(a[i]>a[0] && a[i]<a[n-1])
        count++;
    }
    cout<<count;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n,l,count=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    for(int i=1;i<n-1;i++)
    {
        if(n==1 || n==2)
        {
        count=0;
        break;
    }
        else if(a[i]>a[i-1] && a[i]<a[i+1])
        count++;
    }
    cout<<count;
}


#include<iostream>
using namespace std;
int main()
{
    int n,l,count=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    l=a.size();
    sort(a,a+l);
    for(int i=0;i<n;i++)
    {
        if(a[i]>a[i-1] && a[i]<a[i+1])
        count++;
    }
    cout<<count;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n,l,count=0;
    cin>>n;
    int a[];
    for(int i=0;i<n;i++)
    cin>>a[i];
    l=a.size();
    sort(a,a+l);
    for(int i=0;i<n;i++)
    {
        if(a[i]>a[i-1] && a[i]<a[i+1])
        count++;
    }
    cout<<count;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n,l,count=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    l=strlen(a);
    sort(a,a+l);
    for(int i=0;i<n;i++)
    {
        if(a[i]>a[i-1] && a[i]<a[i+1])
        count++;
    }
    cout<<count;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n,l,count=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        if(n==1 || n==2)
        {
        count=0;
        break;
    }
        else if(a[i]>a[i-1] && a[i]<a[i+1])
        count++;
    }
    cout<<count;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n,l,count=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        if(n==1 || n==2 )
        cout<<"0";
        else(a[i]>a[i-1] && a[i]<a[i+1])
        count++;
    }
    cout<<count;
}


#include <bits/stdc++.h>
using namespace std;

vector<int> v;
int cl[100002];
int ch[100002];
int main() {
    ios::sync_with_stdio(0);
    int n, e;
    cin >> n;
    if (n <= 2) {
        cout << "0";
    } else {
        for (int i = 0; i < n; i++) {
            cin >> e;
            v.push_back(e);
        }
        sort(v.begin(), v.end());
        int count = 0;
        memset(cl, 0, sizeof(cl));
        memset(ch, 0, sizeof(ch));
        for (int i = 1; i < n; i++) {
            if (v[i] > v[i - 1]) {
                cl[i] = cl[i - 1] + 1;
            } else {
                cl[i] = cl[i - 1];
            }
        }
        for (int i = n - 1; i >= 0; i--) {
            if (v[i] < v[i + 1]) {
                ch[i] = ch[i + 1] + 1;
            } else {
                ch[i] = ch[i + 1];
            }
        }
        for (int i = 1; i < n - 1; i++) {
            if (cl[i] > 0 && ch[i] > 0) {
                count++;
            }
        }
        cout << count;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

vector<int> v;
vector<int> cl(100002, 0);
vector<int> ch(100002, 0);
int main() {
    ios::sync_with_stdio(0);
    int n, e;
    cin >> n;
    if (n <= 2) {
        cout << "0";
    } else {
        for (int i = 0; i < n; i++) {
            cin >> e;
            v.push_back(e);
        }
        sort(v.begin(), v.end());
        int count = 0;
        for (int i = 1; i < n - 1; i++) {
            if (v[i] > v[i - 1]) {
                cl[i] = cl[i - 1] + 1;
            } else {
                cl[i] = cl[i - 1];
            }
        }
        for (int i = n - 1; i > 0; i--) {
            if (v[i] < v[i + 1]) {
                ch[i] = ch[i + 1] + 1;
            } else {
                ch[i] = ch[i + 1];
            }
        }
        for (int i = 1; i < n - 1; i++) {
            if (cl[i] > 0 && ch[i] > 0) {
                count++;
            }
        }
        cout << count;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

vector<int> v;
vector<int> cl(100002);
vector<int> ch(100002);
int main() {
    ios::sync_with_stdio(0);
    int n, e;
    cin >> n;
    if (n <= 2) {
        cout << "0";
    } else {
        for (int i = 0; i < n; i++) {
            cin >> e;
            v.push_back(e);
        }
        sort(v.begin(), v.end());
        int count = 0;
        for (int i = 1; i < n; i++) {
            if (v[i] > v[i - 1]) {
                cl[i] = cl[i - 1] + 1;
            } else {
                cl[i] = cl[i - 1];
            }
        }
        for (int i = n - 1; i >= 0; i--) {
            if (v[i] < v[i + 1]) {
                ch[i] = ch[i + 1] + 1;
            } else {
                ch[i] = ch[i + 1];
            }
        }
        for (int i = 1; i < n - 1; i++) {
            if (cl[i] && ch[i]) {
                count++;
            }
        }
        cout << count;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

vector<int> v;
int cl[100002];
int ch[100002];
int main() {
    ios::sync_with_stdio(0);
    int n, e;
    cin >> n;
    if (n <= 2) {
        cout << "0";
    } else {
        for (int i = 0; i < n; i++) {
            cin >> e;
            v.push_back(e);
        }
        sort(v.begin(), v.end());
        int count = 0;
        memset(cl, 0, sizeof(cl));
        memset(ch, 0, sizeof(ch));
        for (int i = 1; i < n - 1; i++) {
            if (v[i] > v[i - 1]) {
                cl[i] = cl[i - 1] + 1;
            } else {
                cl[i] = cl[i - 1];
            }
        }
        for (int i = n - 1; i > 0; i--) {
            if (v[i] < v[i + 1]) {
                ch[i] = ch[i + 1] + 1;
            } else {
                ch[i] = ch[i + 1];
            }
        }
        for (int i = 1; i < n - 1; i++) {
            if (cl[i] > 0 && ch[i] > 0) {
                count++;
            }
        }
        cout << count;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

vector<int> v;
int cl[100002];
int ch[100002];
int main() {
    ios::sync_with_stdio(0);
    int n, e;
    cin >> n;
    if (n <= 2) {
        cout << "0";
    } else {
        for (int i = 0; i < n; i++) {
            cin >> e;
            v.push_back(e);
        }
        sort(v.begin(), v.end());
        int count = 0;
        for (int i = 1; i < n - 1; i++) {
            if (v[i] > v[i - 1]) {
                cl[i] = cl[i - 1] + 1;
            } else {
                cl[i] = cl[i - 1];
            }
        }
        for (int i = n - 1; i > 0; i--) {
            if (v[i] < v[i + 1]) {
                ch[i] = ch[i + 1] + 1;
            } else {
                ch[i] = ch[i + 1];
            }
        }
        for (int i = 1; i < n - 1; i++) {
            if (cl[i] > 0 && ch[i] > 0) {
                count++;
            }
        }
        cout << count;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

vector<int> v;
vector<int> cl(100002, 0);
vector<int> ch(100002, 0);
int main() {
    ios::sync_with_stdio(0);
    int n, e;
    cin >> n;
    if (n <= 2) {
        cout << "0";
    } else {
        for (int i = 0; i < n; i++) {
            cin >> e;
            v.push_back(e);
        }
        sort(v.begin(), v.end());
        int count = 0;
        for (int i = 1; i < n; i++) {
            if (v[i] > v[i - 1]) {
                cl[i] = cl[i - 1] + 1;
            } else {
                cl[i] = cl[i - 1];
            }
        }
        for (int i = n - 1; i >= 0; i--) {
            if (v[i] < v[i + 1]) {
                ch[i] = ch[i + 1] + 1;
            } else {
                ch[i] = ch[i + 1];
            }
        }
        for (int i = 1; i < n - 1; i++) {
            if (cl[i] && ch[i]) {
                count++;
            }
        }
        cout << count;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

vector<int> v;
int main() {
    ios::sync_with_stdio(0);
    int n, e;
    cin >> n;
    if (n <= 2) {
        cout << "0";
    } else {
        for (int i = 0; i < n; i++) {
            cin >> e;
            v.push_back(e);
        }
        sort(v.begin(), v.end());
        int count = 0;
        for (int i = 1; i < n - 1; i++) {
            auto it1 = lower_bound(v.begin() + i + 1, v.end(), v[i] + 1);
            auto it2 = upper_bound(v.begin(), v.begin() + i, v[i] - 1);
            it2--;
            if (*it1 != v[i] && *it2 != v[i]) {
                count++;
            }
        }
        cout << count;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

vector<int> v;
int main() {
    ios::sync_with_stdio(0);
    int n, e;
    cin >> n;
    if (n <= 2) {
        cout << "0";
    } else {
        for (int i = 0; i < n; i++) {
            cin >> e;
            v.push_back(e);
        }
        sort(v.begin(), v.end());
        int count = 0;
        for (int i = 1; i < n - 1; i++) {
            auto it1 = lower_bound(v.begin() + i, v.end(), v[i] + 1);
            auto it2 = upper_bound(v.begin(), v.begin() + i, v[i] - 1);
            it2--;
            if (*it1 != v[i] && *it2 != v[i]) {
                count++;
            }
        }
        cout << count;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int v[100002];
int cl[100002];
int ch[100002];
int main() {
    ios::sync_with_stdio(0);
    int n, e;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> e;
        v[i] = e;
    }
    sort(v, v + n);
    int count = 0;
    memset(cl, 0, sizeof(cl));
    memset(ch, 0, sizeof(ch));
    for (int i = 1; i < n - 1; i++) {
        if (v[i] > v[i - 1]) {
            cl[i] = cl[i - 1] + 1;
        } else {
            cl[i] = cl[i - 1];
        }
    }
    for (int i = n - 1; i >= 1; i--) {
        if (v[i] < v[i + 1]) {
            ch[i] = ch[i + 1] + 1;
        } else {
            ch[i] = ch[i + 1];
        }
    }
    for (int i = 1; i < n - 1; i++) {
        if (cl[i] > 0 && ch[i] > 0) {
            count++;
        }
    }
    cout << count;
    return 0;
}


#include <iostream>
#include <map>

using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);

    int n;
    map<int, int> hashVal;
    cin >> n;
    int arrStewards[n + 5];

    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }

    for (int i = 1; i <= n; ++i)
        cin >> arrStewards[i];

    for (int i = 1; i <= n; ++i)
        hashVal[arrStewards[i]]++;

    cout << n - hashVal[arrStewards[n]] - hashVal[arrStewards[1]] << endl;

    return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);

    int n;
    long long num;
    map<long long, int> hashVal;
    vector<long long> vecStewards;

    cin >> n;

    if (n <= 2) {
        cout << 0 << endl;
        return 0;
    }

    for (int i = 0; i < n; ++i) {
        cin >> num;
        vecStewards.push_back(num);
    }
    cout << vecStewards[n - 1] << ' ' << vecStewards[0] << endl;

    sort(vecStewards.begin(), vecStewards.end());

    for (int i = 0; i < n; ++i)
        hashVal[vecStewards[i]]++;

    cout << n - hashVal[vecStewards[n - 1]] - hashVal[vecStewards[0]] << endl;

    return 0;
}


#include <iostream>
#include <map>

using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);

    int n;
    map<long long, long long> hashVal;
    cin >> n;
    int arrStewards[n + 5];

    if (n <= 1) {
        cout << 0 << endl;
        return 0;
    }

    for (int i = 1; i <= n; ++i)
        cin >> arrStewards[i];

    for (int i = 1; i <= n; ++i)
        hashVal[arrStewards[i]]++;

    cout << n - hashVal[arrStewards[n]] - hashVal[arrStewards[1]] << endl;

    return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int main() {

   int n, res = 0;
   cin >> n;
   int arrStewards[n];

   for (int i = 0; i < n; ++i) {
      cin >> arrStewards[i];
   }

   sort(arrStewards, arrStewards + n);
   for (int i = 0; i < n; ++i) {
      if (arrStewards[i] != arrStewards[0] && arrStewards[i] != arrStewards[n - 1])
         res++;
   }

   cout << res << endl;

   return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);

    int n;
    long long num;
    map<long long, int> hashVal;
    vector<long long> vecStewards;

    cin >> n;

    if (n <= 2) {
        cout << 0 << endl;
        return 0;
    }

    for (int i = 0; i < n; ++i) {
        cin >> num;
        vecStewards.push_back(num);
    }

    sort(vecStewards.begin(), vecStewards.end());

    for (int i = 0; i < n; ++i)
        hashVal[vecStewards[i]]++;

    cout << n - hashVal[vecStewards[n - 1]] - hashVal[vecStewards[0]] << endl;

    return 0;
}


#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);

    int n;
    map<long long, int> hashVal;
    cin >> n;
    long long arrStewards[n + 5];

    if (n <= 1) {
        cout << 0 << endl;
        return 0;
    }

    for (int i = 1; i <= n; ++i)
        cin >> arrStewards[i];

    sort(arrStewards + 1, arrStewards + n + 1);

    for (int i = 1; i <= n; ++i)
        hashVal[arrStewards[i]]++;

    cout << n - hashVal[arrStewards[n]] - hashVal[arrStewards[1]] << endl;

    return 0;
}


#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);

    int n;
    map<int, int> hashVal;
    cin >> n;
    int arrStewards[n + 5];

    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }

    for (int i = 1; i <= n; ++i)
        cin >> arrStewards[i];

    sort(arrStewards + 1, arrStewards + n + 1);

    for (int i = 1; i <= n; ++i)
        hashVal[arrStewards[i]]++;

    cout << n - hashVal[arrStewards[n]] - hashVal[arrStewards[1]] << endl;

    return 0;
}


#include <iostream>
#include <map>

using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);

    int n;
    map<int, int> hashVal;
    cin >> n;
    int arrStewards[n + 5];

    if (n <= 1) {
        cout << 0 << endl;
        return 0;
    }

    for (int i = 1; i <= n; ++i)
        cin >> arrStewards[i];

    for (int i = 1; i <= n; ++i)
        hashVal[arrStewards[i]]++;

    cout << n - hashVal[arrStewards[n]] - hashVal[arrStewards[1]] << endl;

    return 0;
}


#include <iostream>
#include <set>

using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);

    int n, num;
    set<int> s;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> num;
        s.insert(num);
    }

    cout << s.size() - 2 << endl;

    return 0;
}


#include <iostream>
#include <map>

using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);

    int n;
    map<long long, long long> hashVal;
    cin >> n;
    long long arrStewards[n + 5];

    if (n <= 1) {
        cout << 0 << endl;
        return 0;
    }

    for (int i = 1; i <= n; ++i)
        cin >> arrStewards[i];

    for (int i = 1; i <= n; ++i)
        hashVal[arrStewards[i]]++;

    cout << n - hashVal[arrStewards[n]] - hashVal[arrStewards[1]] << endl;

    return 0;
}


#include <iostream>
#include <set>

using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);

    int n, num;
    set<int> s;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> num;
        s.insert(num);
    }

    if (s.size() > 1)
        cout << s.size() - 2 << endl;
    else
        cout << 0 << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
    long long int a[201201],b[201201],i=0,n,c=0;
     cin>>n;
     while(i<n)
     {
     cin>>a[i];
     i++;
     }
      cout<<n-2<<endl;
        return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
    long long int a[201201],b[201201],i=0,n,c=0;
     cin>>n;
     while(i<n)
     {
     cin>>a[i];
     i++;
     }
      sort(a,a+n);
      for(i=0;i<n;i++)
      {
      if(b[i-1]>b[i] && b[i]<b[i+1])
      c++;
      }
      cout<<c<<endl;

        return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
    long long int a[201201],b[201201],i=0,n,c=0;
     cin>>n;
     while(i<n)
     {
     cin>>a[i];
     i++;
     }
      for(i=1;i<n-1;i++)
      {
      if(a[i-1]<a[i] && a[i]<a[i+1])
      c++;
      }
      cout<<c<<endl;

        return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
    long long int a[201201],b[201201],i=0,n,c=0;
     cin>>n;
     while(i<n)
     {
     cin>>a[i];
     i++;
     }
     sort(a,a+n);
     for(i=0;i<n;i++)
     {
         if(a[i]==a[i+1])c++;
     }
      cout<<n-2-c<<endl;
        return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
    long long int a[201201],b[201201],i=0,n,c=0;
     cin>>n;
     while(i<n)
     {
     cin>>a[i];
     i++;
     }
      sort(a,a+n);
      for(i=1;i<n-1;i++)
      {
      if(a[i-1]<a[i] && a[i]<a[i+1])
      c++;
      }
      cout<<c<<endl;

        return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
    long long int a[201201],b[201201],i=0,n,c=0;
     cin>>n;
     while(i<n)
     {
     cin>>a[i];
     b[i]=a[i];
     i++;
     }
      sort(b,b+n);
      for(i=0;i<n;i++)
      {
      if(b[i]==b[i+1])
      c++;
      }
      cout<<n-2-c<<endl;

        return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
    long long int a[201201],b[201201],i=0,n,c=0;
     cin>>n;
     while(i<n)
     {
     cin>>a[i];
     i++;
     }
     sort(a,a+n);
     for(i=0;i<n;i++)
     {
         if(a[0]<a[i] && a[n-1]>a[i])c++;
     }
      cout<<c<<endl;
        return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , a , c=0 ;
    cin >> n ;
    vector<int>v;
    for(int i=0 ; i < n ; i ++)
    {
        cin >> a ;
        v.push_back(a);
    }
    for(int i=1 ; i < n-1 ; i++)
    {
        if(v[i]>v[i-1]&&v[i]<v[2])
            c++;
    }
    cout << c <<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , a , b=0 ;
    cin >> n ;
    vector<int>v;
    for(int i=0 ; i < n ; i ++)
    {
        cin >> a ;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    //v.reserve(unique(v.begin(),v.end())-v.begin());
    for(int i=1 ; i < n-1 ; i++)
    {
        if(v[i]>v[i-1]&&v[i]<v[i+1])
            b++;
    }
    cout << b <<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , a , b=0 ;
    cin >> n ;
    vector<int>v;
    for(int i=0 ; i < n ; i ++)
    {
        cin >> a ;
        v.push_back(a);
    }

    sort(v.begin(),v.end());
    v.reserve(unique(v.begin(),v.end())-v.begin());
    cout << n /3 << endl;

}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , a , c=0 ;
    cin >> n ;
    vector<int>v;
    for(int i=0 ; i < n ; i ++)
    {
        cin >> a ;
        v.push_back(a);
    }
    for(int i=1 ; i < n-1 ; i++)
    {
        if(v[i]>v[i-1]&&v[i]<v[i+1])
            c++;
    }
    cout << c <<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , a ;
    cin >> n ;
    vector<int>v;
    for(int i=0 ; i < n ; i ++)
    {
        cin >> a ;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    v.resize(unique(v.begin(),v.end())-v.begin());
    if(n<=2)
        cout << 0 <<endl;
    else
        cout << v.size()-2 <<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , a , b=0 ;
    cin >> n ;
    vector<int>v;
    for(int i=0 ; i < n ; i ++)
    {
        cin >> a ;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    for(int i=1 ; i < n-1 ; i++)
    {
        if(v[i]<v[i+1])
            b++;
    }
    cout << b <<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , a ;
    cin >> n ;
    vector<int>v;
    for(int i=0 ; i < n ; i ++)
    {
        cin >> a ;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    //v.resize(unique(v.begin(),v.end())-v.begin());
    if(n<=2)
        cout << 0 <<endl;
    else
        cout << v.size()-2 <<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , a , b=0 ;
    cin >> n ;
    vector<int>v;
    for(int i=0 ; i < n ; i ++)
    {
        cin >> a ;
        v.push_back(a);
    }
    for(int i=1 ; i < n-1 ; i++)
    {
        if(v[i]>v[i-1]&&v[i]<v[i+1])
            b++;
    }
    cout << b <<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , a , b=0 ;
    cin >> n ;
    vector<int>v;
    for(int i=0 ; i < n ; i ++)
    {
        cin >> a ;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    v.reserve(unique(v.begin(),v.end())-v.begin());
    for(int i=1 ; i < n-1 ; i++)
    {
        if(v[i]>v[i-1]&&v[i]<v[i+1])
            b++;
    }
    cout << b <<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , a , b=0 ;
    cin >> n ;
    vector<int>v;
    for(int i=0 ; i < n ; i ++)
    {
        cin >> a ;
        v.push_back(a);
    }
    for(int i=1 ; i < n-1 ; i++)
    {
        if(v[i]<=v[i+1])
            b++;
    }
    cout << b <<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , a ;
    cin >> n ;
    vector<int>v;
    for(int i=0 ; i < n ; i ++)
    {
        cin >> a ;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    //v.resize(unique(v.begin(),v.end())-v.begin());
    if(n<2)
        cout << 0 <<endl;
    else
        cout << v.size()-2 <<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false), cin.tie(0);
    int n , a , b=0 ;
    cin >> n ;
    vector<int>v;
    for(int i=0 ; i < n ; i ++)
    {
        cin >> a ;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    for(int i=1 ; i <n ; i++)
    {
        if(v[i]<v[n-1])
            b++;
    }
    cout << b <<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , a ;
    cin >> n ;
    vector<int>v;
    for(int i=0 ; i < n ; i ++)
    {
        cin >> a ;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    v.resize(unique(v.begin(),v.end())-v.begin());
    if(n<2)
        cout << 0 <<endl;
    else
        cout << v.size()-2 <<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , a ;
    cin >> n ;
    vector<int>v;
    for(int i=0 ; i < n ; i ++)
    {
        cin >> a ;
        v.push_back(a);
    }
    if(n<=2)
        cout << 0 <<endl;
    else
        cout << v.size()-2 <<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false), cin.tie(0);
    int n , a , b=0 ;
    cin >> n ;
    vector<int>v;
    for(int i=0 ; i < n ; i ++)
    {
        cin >> a ;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    for(int i=1 ; i <n ; i++)
    {
        if(v[i]!=v[0]&&v[i]<v[n-1])
            b++;
    }
    cout << b <<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , a , b=0 ;
    cin >> n ;
    vector<int>v;
    for(int i=0 ; i < n ; i ++)
    {
        cin >> a ;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    //v.reserve(unique(v.begin(),v.end())-v.begin());
    for(int i=1 ; i < n-1 ; i++)
    {
        if(v[i]<=v[i+1])
            b++;
    }
    cout << b <<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , a , c=0 ;
    cin >> n ;
    vector<int>v;
    for(int i=0 ; i < n ; i ++)
    {
        cin >> a ;
        v.push_back(a);
    }
    for(int i=1 ; i < n-1 ; i++)
    {
        if(v[i]>=v[i-1]&&v[i]<=v[2])
            c++;
    }
    cout << c <<endl;
}


#include <iostream>

using namespace std;

int main()
{
int n,m=0,nn=0,minm=1000000000,maxm=0;
cin>>n;
int a[n];
for(int x=0;x<n;x++)
cin>>a[x];
again:
for(int x=0;x<n-2;x++)
{
    if (a[x+1]<a[x])
    {
     if (a[x+2]<a[x])
     {
        swap(a[x+2],a[x]);
        goto again;
     }
     swap(a[x+1],a[x]);
     goto again;
    }
}
for(int x=0;x<n;x++)
{
   if (a[x]>a[0]&&a[x]<a[n-1])
    nn++;

}
//nn=(minm<a[x]&&a[x]<maxm)?++nn:nn;
//{
 //if(minm<a[x]&&a[x]<maxm)
 //nn++;
//}
  //  nn=minm<a[x]<maxm?nn++:nn;
cout<<nn<<endl;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
int n,nn=0,minm=1000000000,maxm=0;
cin>>n;
int a[n];
for(int x=0;x<n;x++)
cin>>a[x];
for(int x=0;x<n;x++)
{
 minm=a[x]<minm?a[x]:minm;
 maxm=a[x]>maxm?a[x]:maxm;
}
for(int x=0;x<n;x++)
nn=(minm<a[x]&&a[x]<maxm)?++nn:nn;
//{
 //if(minm<a[x]&&a[x]<maxm)
 //nn++;
//}
  //  nn=minm<a[x]<maxm?nn++:nn;
cout<<nn<<endl;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
int n,m=0,nn=0,minm=1000000000,maxm=0;
cin>>n;
int a[n];
for(int x=0;x<n;x++)
cin>>a[x];
again:
for(int x=0;x<n-1;x++)
{
    if (a[x+1]<a[x])
    {swap(a[x+1],a[x]);
    goto again;}
}
for(int x=0;x<n;x++)
{
   if (a[x]>a[0]&&a[x]<a[n-1])
    nn++;

}
//nn=(minm<a[x]&&a[x]<maxm)?++nn:nn;
//{
 //if(minm<a[x]&&a[x]<maxm)
 //nn++;
//}
  //  nn=minm<a[x]<maxm?nn++:nn;
cout<<nn<<endl;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
int n,m=0,nn=0,minm=1000000000,maxm=0;
cin>>n;
int a[n];
for(int x=0;x<n;x++)
cin>>a[x];

for(int x=0;x<n;x++)
{
    for(int y=x;y<n;y++)
    {
        if(a[y]<a[x])
            swap(a[y],a[x]);
    }
}
for(int x=0;x<n;x++)
{
    //cout<<a[x]<<" ";
    if (a[x]>a[0]&&a[x]<a[n-1])
    nn++;

}
//nn=(minm<a[x]&&a[x]<maxm)?++nn:nn;
//{
 //if(minm<a[x]&&a[x]<maxm)
 //nn++;
//}
  //  nn=minm<a[x]<maxm?nn++:nn;
cout<<nn<<endl;

    return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;
int main(){
int n;
while(cin>>n){int a[n];
for(int i=0;i<n;i++)cin>>a[i];
sort(a,a+n);
int fs=0,es=0;
for(int i=0;i<n;i++)
{if(a[i]==a[0])fs++;
 if(a[n-1-i]==a[n-1])es++;}
int num=n-fs-es;
cout<<(num<=0?0:num)<<endl;
}return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n,num=0;cin>>n;
int a[n];for(int i=0;i<n;i++)cin>>a[i];
sort(a,a+n);
for(int i=0;i<n;i++){if(a[i]!=a[0]&&a[i]!=a[n-1])num++;}
cout<<num<<endl;
return 0;}


#include <iostream>

using namespace std;

int main()
{
int n,m=0,nn=0,minm=1000000000,maxm=0;
cin>>n;
int a[n];
for(int x=0;x<n;x++)
cin>>a[x];

for(int x=0;x<n;x++)
{
    for(int y=x;y<n;y++)
    {
        if(a[y]<a[x])
            swap(a[y],a[x]);
    }
}
for(int x=0;x<n;x++)
{
    cout<<a[x]<<" ";
   if (a[x]>a[0]&&a[x]<a[n-1])
    nn++;

}
//nn=(minm<a[x]&&a[x]<maxm)?++nn:nn;
//{
 //if(minm<a[x]&&a[x]<maxm)
 //nn++;
//}
  //  nn=minm<a[x]<maxm?nn++:nn;
cout<<nn<<endl;

    return 0;
}


#include<iostream>

using namespace std;

void gnomeSort(int arr[], int n)
{
    int index = 0;

    while (index < n) {
        if (index == 0)
            index++;
        if (arr[index] >= arr[index - 1])
            index++;
        else {
            swap(arr[index], arr[index - 1]);
            index--;
        }
    }
}

int main(){
    long n, maxvalue = 0, minvalue = -10, counter =0;
    bool checkmin = false;
    cin>>n;
    int arr[n];
    for(int i =0; i < n; i++)
    {
        cin>>arr[i];
        if(arr[i]>maxvalue)
        {
            maxvalue = arr[i];
        }
        if(checkmin == false)
        {
            checkmin = true;
            minvalue = arr[i];
        }
        if(minvalue > arr[i]&&checkmin == true)
        {
            minvalue = arr[i];
        }
    }
    gnomeSort(arr, n);
    for (int i =0; i<n; i++)
    {
        if(arr[i]>minvalue && arr[i]<maxvalue)
        {
            counter++;
        }
    }
    cout<<counter<<endl;
    return 0;
}


#include<iostream>

using namespace std;

void mergeback (int *arr, long low, long high, long mid)
{
    long a;
    long b;
    long c;
    long d[high-low+1];

    a = low;
    c = 0;
    b = mid+1;

    while (a <= mid && b <= high)
    {
        if (arr[a] < arr[b])
        {
            d[c] = arr[a];
            c++;
            a++;
        }
        else
        {
            d[c] = arr[b];
            c++;
            b++;
        }
    }

    while (a <= mid)
    {
        d[c] = arr[a];
        c++;
        a++;
    }

    while (b <= high)
    {
        d[c] = arr[b];
        c++;
        b++;
    }

    for (a = low; a <= high; a++)
    {
        arr[a] = d[a-low];
    }
}

void mergesort(int *arr, long low, long high)
{
    long mid;
    if (low < high)
    {
        mid = (low+high)/2;

        mergesort(arr, low, mid);
        mergesort(arr, mid+1, high);

        mergeback(arr, low, high, mid);
    }
}

int main(){
    long n, maxvalue = 0, minvalue = -10, counter =0;
    bool checkmin = false;
    cin>>n;
    int arr[n];
    for(int i =0; i < n; i++)
    {
        cin>>arr[i];
        if(arr[i]>maxvalue)
        {
            maxvalue = arr[i];
        }
        if(checkmin == false)
        {
            checkmin = true;
            minvalue = arr[i];
        }
        if(minvalue > arr[i]&&checkmin == true)
        {
            minvalue = arr[i];
        }
    }
    mergesort(arr,0,n-1);
    for (int i =0; i<n; i++)
    {
        if(arr[i]>minvalue && arr[i]<maxvalue)
        {
            counter++;
        }
    }
    cout<<counter<<endl;
    return 0;
}


#include<iostream>

using namespace std;

void sleepSort(int arr[], int n)
{
    HANDLE threads[n];

    for (int i = 0; i < n; i++)
        threads[i] = (HANDLE)_beginthread(&routine, 0,  &arr[i]);

    WaitForMultipleObjects(n, threads, TRUE, INFINITE);
    return;
}

int main(){
    long n, maxvalue = 0, minvalue = -10, counter =0;
    bool checkmin = false;
    cin>>n;
    int arr[n];
    for(int i =0; i < n; i++)
    {
        cin>>arr[i];
        if(arr[i]>maxvalue)
        {
            maxvalue = arr[i];
        }
        if(checkmin == false)
        {
            checkmin = true;
            minvalue = arr[i];
        }
        if(minvalue > arr[i]&&checkmin == true)
        {
            minvalue = arr[i];
        }
    }
    sleepSort(arr, n);
    for (int i =0; i<n; i++)
    {
        if(arr[i]>minvalue && arr[i]<maxvalue)
        {
            counter++;
        }
    }
    cout<<counter<<endl;
    return 0;
}


#include<iostream>

using namespace std;

void CocktailSort(int a[], int n)
{
    bool swapped = true;
    int start = 0;
    int end = n - 1;

    while (swapped) {
        // reset the swapped flag on entering
        // the loop, because it might be true from
        // a previous iteration.
        swapped = false;

        // loop from left to right same as
        // the bubble sort
        for (int i = start; i < end; ++i) {
            if (a[i] > a[i + 1]) {
                swap(a[i], a[i + 1]);
                swapped = true;
            }
        }

        // if nothing moved, then array is sorted.
        if (!swapped)
            break;

        // otherwise, reset the swapped flag so that it
        // can be used in the next stage
        swapped = false;

        // move the end point back by one, because
        // item at the end is in its rightful spot
        --end;

        // from right to left, doing the
        // same comparison as in the previous stage
        for (int i = end - 1; i >= start; --i) {
            if (a[i] > a[i + 1]) {
                swap(a[i], a[i + 1]);
                swapped = true;
            }
        }

        // increase the starting point, because
        // the last stage would have moved the next
        // smallest number to its rightful spot.
        ++start;
    }
}

int main(){
    long n, maxvalue = 0, minvalue = -10, counter =0;
    bool checkmin = false;
    cin>>n;
    int arr[n];
    for(int i =0; i < n; i++)
    {
        cin>>arr[i];
        if(arr[i]>maxvalue)
        {
            maxvalue = arr[i];
        }
        if(checkmin == false)
        {
            checkmin = true;
            minvalue = arr[i];
        }
        if(minvalue > arr[i]&&checkmin == true)
        {
            minvalue = arr[i];
        }
    }
    CocktailSort(arr, n);
    for (int i =0; i<n; i++)
    {
        if(arr[i]>minvalue && arr[i]<maxvalue)
        {
            counter++;
        }
    }
    cout<<counter<<endl;
    return 0;
}


#include<iostream>

using namespace std;

void mergeback (long long *arr, long long low, long long high, long long mid)
{
    long a;
    long b;
    long c;
    long d[high-low+1];

    a = low;
    c = 0;
    b = mid+1;

    while (a <= mid && b <= high)
    {
        if (arr[a] < arr[b])
        {
            d[c] = arr[a];
            c++;
            a++;
        }
        else
        {
            d[c] = arr[b];
            c++;
            b++;
        }
    }

    while (a <= mid)
    {
        d[c] = arr[a];
        c++;
        a++;
    }

    while (b <= high)
    {
        d[c] = arr[b];
        c++;
        b++;
    }

    for (a = low; a <= high; a++)
    {
        arr[a] = d[a-low];
    }
}

void mergesort(long long *arr, long long low, long long high)
{
    long long mid;
    if (low < high)
    {
        mid = (low+high)/2;

        mergesort(arr, low, mid);
        mergesort(arr, mid+1, high);

        mergeback(arr, low, high, mid);
    }
}

int main(){
    long long n, maxvalue = 0, minvalue = -10, counter =0;
    bool checkmin = false;
    cin>>n;
    int arr[n];
    for(int i =0; i < n; i++)
    {
        cin>>arr[i];
        if(arr[i]>maxvalue)
        {
            maxvalue = arr[i];
        }
        if(checkmin == false)
        {
            checkmin = true;
            minvalue = arr[i];
        }
        if(minvalue > arr[i]&&checkmin == true)
        {
            minvalue = arr[i];
        }
    }
    mergesort(arr,0,n-1);
    for (int i =0; i<n; i++)
    {
        if(arr[i]>minvalue && arr<maxvalue)
        {
            counter++
        }
    }
    cout<<counter<<endl;
    return 0;
}


#include<iostream>

using namespace std;

void gnomeSort(int arr[], long n)
{
    int index = 0;

    while (index < n) {
        if (index == 0)
            index++;
        if (arr[index] >= arr[index - 1])
            index++;
        else {
            swap(arr[index], arr[index - 1]);
            index--;
        }
    }
}

int main(){
    long n, maxvalue = 0, minvalue = -10, counter =0;
    bool checkmin = false;
    cin>>n;
    int arr[n];
    for(int i =0; i < n; i++)
    {
        cin>>arr[i];
        if(arr[i]>maxvalue)
        {
            maxvalue = arr[i];
        }
        if(checkmin == false)
        {
            checkmin = true;
            minvalue = arr[i];
        }
        if(minvalue > arr[i]&&checkmin == true)
        {
            minvalue = arr[i];
        }
    }
    gnomeSort(arr, n);
    for (int i =0; i<n; i++)
    {
        if(arr[i]>minvalue && arr[i]<maxvalue)
        {
            counter++;
        }
    }
    cout<<counter<<endl;
    return 0;
}


#include<iostream>

using namespace std;

void heapify(int arr[], int n, int i)
{
    int largest = i; // Initialize largest as root
    int l = 2*i + 1; // left = 2*i + 1
    int r = 2*i + 2; // right = 2*i + 2

    // If left child is larger than root
    if (l < n && arr[l] > arr[largest])
        largest = l;

    // If right child is larger than largest so far
    if (r < n && arr[r] > arr[largest])
        largest = r;

    // If largest is not root
    if (largest != i)
    {
        swap(arr[i], arr[largest]);

        // Recursively heapify the affected sub-tree
        heapify(arr, n, largest);
    }
}

// main function to do heap sort
void heapSort(int arr[], int n)
{
    // Build heap (rearrange array)
    for (int i = n / 2 - 1; i >= 0; i--)
        heapify(arr, n, i);

    // One by one extract an element from heap
    for (int i=n-1; i>=0; i--)
    {
        // Move current root to end
        swap(arr[0], arr[i]);

        // call max heapify on the reduced heap
        heapify(arr, i, 0);
    }
}

int main(){
    long n, maxvalue = 0, minvalue = -10, counter =0;
    bool checkmin = false;
    cin>>n;
    int arr[n];
    for(int i =0; i < n; i++)
    {
        cin>>arr[i];
        if(arr[i]>maxvalue)
        {
            maxvalue = arr[i];
        }
        if(checkmin == false)
        {
            checkmin = true;
            minvalue = arr[i];
        }
        if(minvalue > arr[i]&&checkmin == true)
        {
            minvalue = arr[i];
        }
    }
    heapSort(arr, n);
    for (int i =0; i<n; i++)
    {
        if(arr[i]>minvalue && arr[i]<maxvalue)
        {
            counter++;
        }
    }
    cout<<counter<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, cnt = 0;
    vector<int> nrs;
    cin >> n;
    nrs.reserve(n);

    int nr;
    while (n--)
    {
        cin >> nr;
        nrs.emplace_back(nr);
    }
    sort(nrs.begin(), nrs.end());

    for (int i = 1; i < nrs.size() - 1; ++i)
    {
        if (nrs[i] > nrs[i - 1] && nrs[i] < nrs[i + 1])
        {
            ++cnt;
        }
    }

    cout << cnt;
}


#include <iostream>
#include <unordered_set>
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, nr;
    unordered_set<int> nrs;
    cin >> n;

    while (n--)
    {
        cin >> nr;
        nrs.emplace(nr);
    }

    if (n == 1)
    {
        cout << 0;
    }
    else
    {
        cout << nrs.size() - 2;
    }
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, cnt = 0;
    vector<int> nrs;
    cin >> n;
    nrs.reserve(n);

    int nr;
    while (n--)
    {
        cin >> nr;
        nrs.emplace_back(n);
    }
    sort(nrs.begin(), nrs.end());

    for (int i = 1; i < nrs.size() - 1; ++i)
    {
        if (nrs[i] > nrs[i - 1] && nrs[i] < nrs[i + 1])
        {
            ++cnt;
        }
    }

    cout << cnt;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, cnt = 0;
    vector<int> nrs;
    cin >> n;
    nrs.reserve(n);

    int nr;
    int lowest_elem = 1e9, highest_elem = 0;
    while (n--)
    {
        cin >> nr;
        lowest_elem = min(lowest_elem, nr);
        highest_elem = max(highest_elem, nr);
        nrs.emplace_back(nr);
    }

    for (int i = 1; i < nrs.size() - 1; ++i)
    {
        if (nrs[i] > lowest_elem && nrs[i] < highest_elem)
        {
            ++cnt;
        }
    }

    cout << cnt;
}


#include <bits/stdc++.h>

using namespace std;

int n,m,i,x,y,q,tp,v,Ans,j;
vector<int>g[100005];
bitset<1000>t[400005];
int tag[400005];
int ps[100005];
int sz[100005];
bitset<1000>X;
int a[100005];
int ord[100005];
bool vis[100005];
int P[2222];

void dfs(int x,int p)
{
    ord[++q]=x;
    ps[x]=q,sz[x]=1;
    for(int i=0;i<g[x].size();i++)
    {
        if(g[x][i]==p)continue;
        dfs(g[x][i],x);
        sz[x]+=sz[g[x][i]];
    }
}

void Build(int x,int l,int r)
{
    if(l==r)t[x].set(a[ord[l]]%m);
    else
    {
        int mid=(l+r)>>1;
        Build(x+x,l,mid);
        Build(x+x+1,mid+1,r);
        t[x]=t[x+x]|t[x+x+1];
    }
}
void Push(int x)
{
    tag[x]%=m;
    if(tag[x]!=0)
    {
        tag[x]%=m;
        t[x]=(t[x]<<tag[x])&X)|(t[x]>>(m-tag[x]));
        tag[x+x]+=tag[x];
        tag[x+x+1]+=tag[x];
        tag[x+x]%=m;
        tag[x+x+1]%=m;
        tag[x]=0;
    }
}
void Rotate(int x,int l,int r,int ll,int rr,int shi)
{
    Push(x);
    if(l==ll&&r==rr)
    {
        tag[x]+=shi;
        tag[x]%=m;
        Push(x);
    }
    else
    {
        Push(x);
        int mid=(l+r)>>1;
        if(rr<=mid)Rotate(x+x,l,mid,ll,rr,shi);
        else if(ll>mid)Rotate(x+x+1,mid+1,r,ll,rr,shi);
        else
        {
            Rotate(x+x,l,mid,ll,mid,shi);
            Rotate(x+x+1,mid+1,r,mid+1,rr,shi);
        }
        t[x]=t[x+x]|t[x+x+1];
        Push(x);
    }
    Push(x);
}
bitset<1000> Query(int x,int l,int r,int ll,int rr)
{
    Push(x);
    if(l==ll&&r==rr)return t[x];
    else
    {
        Push(x);
        int mid=(l+r)>>1;
        if(rr<=mid)return Query(x+x,l,mid,ll,rr);
        else if(ll>mid)return Query(x+x+1,mid+1,r,ll,rr);
        else
        {
            bitset<1000>A=Query(x+x,l,mid,ll,mid);
            bitset<1000>B=Query(x+x+1,mid+1,r,mid+1,rr);
            return A|B;
        }
    }
    Push(x);
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<n;i++)
    {
        scanf("%d%d",&x,&y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i=0;i<m;i++)X.set(i);
    for(int i=2;i<m;i++)if(!vis[i])
    {
        P[++P[0]]=i;
        for(int j=2*i;j<m;j+=i)vis[j]=1;
    }
    dfs(1,-1);
    Build(1,1,n);
    scanf("%d",&q);
    for(int i=1;i<=q;i++)
    {
        scanf("%d",&tp);
        if(tp==1)
        {
            scanf("%d%d",&v,&x);
            Rotate(1,1,n,ps[v],ps[v]+sz[v]-1,x%m);
        }
        else
        {
            scanf("%d",&v);
            Ans=0;
            bitset<1000>A=Query(1,1,n,ps[v],ps[v]+sz[v]-1)&X;
            for(int j=1;j<=P[0];j++)Ans+=A.test(P[j]);
            printf("%d\n",Ans);
        }
    }
    return 0;
}