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

namespace FertiLib.Contest.C
{
	static class Program
	{
		public static void Solve(Scanner cin)
		{
			long n = cin.ReadLong();
			ModInt ans = 1;
			for (int i = 1; i <= n; i++)
			{
				ans *= i;
			}
			ans -= ModInt.Pow(2, n - 1);
			Console.WriteLine(ans);
		}

		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);
			var cin = new Scanner();
			Solve(cin);
			Console.Out.Flush();
		}

		public static void YESNO(bool condition) => Console.WriteLine(condition ? "YES" : "NO");
		public static void YesNo(bool condition) => Console.WriteLine(condition ? "Yes" : "No");
		public static void yesno(bool condition) => Console.WriteLine(condition ? "yes" : "no");
	}
	public struct ModInt : IComparable<ModInt>, IEquatable<ModInt>
	{
		public static long MOD = 1000000007;
		public static bool isModPrime { get; set; }

		private readonly long num;

		public ModInt(long n) { num = n; isModPrime = true; }

		public override string ToString() => num.ToString();

		public static ModInt operator +(ModInt l, ModInt r)
		{
			long x = l.num + r.num;
			if (x >= MOD) x -= MOD;
			return new ModInt(x);
		}
		public static ModInt operator -(ModInt l, ModInt r)
		{
			long x = l.num - r.num;
			if (x < 0) x += MOD;
			return new ModInt(x);
		}
		public static ModInt operator *(ModInt l, ModInt r) => new ModInt((l.num * r.num) % MOD);
		public static ModInt operator /(ModInt l, ModInt r) => l * r.Inverse();

		public static ModInt operator ++(ModInt x)
		{
			var tmp = x + new ModInt(1);
			return tmp;
		}
		public static ModInt operator --(ModInt x)
		{
			var tmp = x - new ModInt(1);
			return tmp;
		}

		public static bool operator >(ModInt l, ModInt r) => l.CompareTo(r) > 0;
		public static bool operator <(ModInt l, ModInt r) => l.CompareTo(r) < 0;
		public static bool operator >=(ModInt l, ModInt r) => l.CompareTo(r) >= 0;
		public static bool operator <=(ModInt l, ModInt r) => l.CompareTo(r) <= 0;
		public static bool operator ==(ModInt l, ModInt r) => l.Equals(r);
		public static bool operator !=(ModInt l, ModInt r) => !l.Equals(r);

		public static implicit operator long(ModInt x) => x.num;
		public static implicit operator ModInt(long n)
		{
			n %= MOD;
			if (n < 0) n += MOD;
			return new ModInt(n);
		}

		public ModInt Inverse() => Inverse(this, MOD);
		public static ModInt Inverse(ModInt x) => Inverse(x.num, MOD);
		public static long Inverse(long x, long m)
		{
			if (x % m == 0) throw new DivideByZeroException();
			long a = x, b = m, u = 1, v = 0;
			while (b > 0)
			{
				long t = a / b;

				a -= t * b;
				long p = a; a = b; b = p;   // swap(a, b);

				u -= t * v;
				p = u; u = v; v = p;        // swap(u, v);
			}
			u %= m;
			if (u < 0) u += m;
			return u;
		}

		public static ModInt Pow(long x, long n)
		{
			long now = 1;
			if (isModPrime) n %= MOD - 1;
			for (; n > 0; n /= 2, x = x * x % MOD)
			{
				if (n % 2 == 1) now = now * x % MOD;
			}
			return new ModInt(now);
		}

		public int CompareTo(ModInt x)
		{
			if (num == x.num) return 0;
			if (num > x.num) return 1;
			return -1;
		}

		public bool Equals(ModInt x) => num == x.num;

		public override bool Equals(object obj) => obj is ModInt m && num == m.num;
	}

	static class Util
	{
		public static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
	}

	class Printer : StreamWriter
	{
		public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
		public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
		public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { }
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] separator = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Read() => ReadString();

		public string ReadString()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(separator, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return ReadString();
			i = 0;
			return s[i++];
		}

		public string[] ReadStringArray(int N)
		{
			string[] Array = new string[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadString();
			}
			return Array;
		}

		public int ReadInt()
		{
			return int.Parse(ReadString());
		}

		public int[] ReadIntArray(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadInt() + add;
			}
			return Array;
		}

		public long ReadLong()
		{
			return long.Parse(ReadString());
		}

		public long[] ReadLongArray(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadLong() + add;
			}
			return Array;
		}

		public double ReadDouble()
		{
			return double.Parse(ReadString());
		}

		public double[] ReadDoubleArray(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadDouble() + add;
			}
			return Array;
		}

		public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1));

		public (T1, T2) ReadValue<T1, T2>()
		{
			var inputs = ReadStringArray(2);
			var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
			var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
			return (v1, v2);
		}

		public (T1, T2, T3) ReadValue<T1, T2, T3>()
		{
			var inputs = ReadStringArray(3);
			var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
			var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
			var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
			return (v1, v2, v3);
		}

		public (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>()
		{
			var inputs = ReadStringArray(4);
			var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
			var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
			var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
			var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
			return (v1, v2, v3, v4);
		}

		public (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>()
		{
			var inputs = ReadStringArray(5);
			var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
			var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
			var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
			var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
			var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
			return (v1, v2, v3, v4, v5);
		}

		public (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>()
		{
			var inputs = ReadStringArray(6);
			var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
			var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
			var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
			var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
			var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
			var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));
			return (v1, v2, v3, v4, v5, v6);
		}

		public (T1, T2, T3, T4, T5, T6, T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>()
		{
			var inputs = ReadStringArray(7);
			var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
			var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
			var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
			var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
			var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
			var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));
			var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7));
			return (v1, v2, v3, v4, v5, v6, v7);
		}

		public T1[] ReadValueArray<T1>(int N)
		{
			var v1 = new T1[N];
			for (int i = 0; i < N; i++)
			{
				v1[i] = ReadValue<T1>();
			}
			return v1;
		}

		public (T1[], T2[]) ReadValueArray<T1, T2>(int N)
		{
			var (v1, v2) = (new T1[N], new T2[N]);
			for (int i = 0; i < N; i++)
			{
				var (t1, t2) = ReadValue<T1, T2>();
				v1[i] = t1;
				v2[i] = t2;
			}
			return (v1, v2);
		}

		public (T1[], T2[], T3[]) ReadValueArray<T1, T2, T3>(int N)
		{
			var (v1, v2, v3) = (new T1[N], new T2[N], new T3[N]);
			for (int i = 0; i < N; i++)
			{
				var (t1, t2, t3) = ReadValue<T1, T2, T3>();
				v1[i] = t1;
				v2[i] = t2;
				v3[i] = t3;
			}
			return (v1, v2, v3);
		}

		public (T1[], T2[], T3[], T4[]) ReadValueArray<T1, T2, T3, T4>(int N)
		{
			var (v1, v2, v3, v4) = (new T1[N], new T2[N], new T3[N], new T4[N]);
			for (int i = 0; i < N; i++)
			{
				var (t1, t2, t3, t4) = ReadValue<T1, T2, T3, T4>();
				v1[i] = t1;
				v2[i] = t2;
				v3[i] = t3;
				v4[i] = t4;
			}
			return (v1, v2, v3, v4);
		}

		public (T1[], T2[], T3[], T4[], T5[]) ReadValueArray<T1, T2, T3, T4, T5>(int N)
		{
			var (v1, v2, v3, v4, v5) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N]);
			for (int i = 0; i < N; i++)
			{
				var (t1, t2, t3, t4, t5) = ReadValue<T1, T2, T3, T4, T5>();
				v1[i] = t1;
				v2[i] = t2;
				v3[i] = t3;
				v4[i] = t4;
				v5[i] = t5;
			}
			return (v1, v2, v3, v4, v5);
		}

		public (T1[], T2[], T3[], T4[], T5[], T6[]) ReadValueArray<T1, T2, T3, T4, T5, T6>(int N)
		{
			var (v1, v2, v3, v4, v5, v6) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N]);
			for (int i = 0; i < N; i++)
			{
				var (t1, t2, t3, t4, t5, t6) = ReadValue<T1, T2, T3, T4, T5, T6>();
				v1[i] = t1;
				v2[i] = t2;
				v3[i] = t3;
				v4[i] = t4;
				v5[i] = t5;
				v6[i] = t6;
			}
			return (v1, v2, v3, v4, v5, v6);
		}

		public (T1[], T2[], T3[], T4[], T5[], T6[], T7[]) ReadValueArray<T1, T2, T3, T4, T5, T6, T7>(int N)
		{
			var (v1, v2, v3, v4, v5, v6, v7) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N], new T7[N]);
			for (int i = 0; i < N; i++)
			{
				var (t1, t2, t3, t4, t5, t6, t7) = ReadValue<T1, T2, T3, T4, T5, T6, T7>();
				v1[i] = t1;
				v2[i] = t2;
				v3[i] = t3;
				v4[i] = t4;
				v5[i] = t5;
				v6[i] = t6;
				v7[i] = t7;
			}
			return (v1, v2, v3, v4, v5, v6, v7);
		}
	}
}


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

namespace FertiLib.Contest.C
{
	static class Program
	{
		public static void Solve(Scanner cin)
		{
			long n = cin.ReadLong();
			ModInt ans = 1;
			for (int i = 1; i <= n; i++)
			{
				ans *= i;
			}
			ans -= ModInt.Pow(2, n - 1);
			Console.WriteLine(ans);
		}

		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);
			var cin = new Scanner();
			Solve(cin);
			Console.Out.Flush();
		}

		public static void YESNO(bool condition) => Console.WriteLine(condition ? "YES" : "NO");
		public static void YesNo(bool condition) => Console.WriteLine(condition ? "Yes" : "No");
		public static void yesno(bool condition) => Console.WriteLine(condition ? "yes" : "no");
	}
	public struct ModInt : IComparable<ModInt>, IEquatable<ModInt>
	{
		public static long MOD = 1000000007;
		public static bool isModPrime { get; set; }

		private readonly long num;

		public ModInt(long n) { num = n; isModPrime = true; }

		public override string ToString() => num.ToString();

		public static ModInt operator +(ModInt l, ModInt r)
		{
			long x = l.num + r.num;
			if (x >= MOD) x -= MOD;
			return new ModInt(x);
		}
		public static ModInt operator -(ModInt l, ModInt r)
		{
			long x = l.num - r.num;
			if (x < 0) x += MOD;
			return new ModInt(x);
		}
		public static ModInt operator *(ModInt l, ModInt r) => new ModInt((l.num * r.num) % MOD);
		public static ModInt operator /(ModInt l, ModInt r) => l * r.Inverse();

		public static ModInt operator ++(ModInt x)
		{
			var tmp = x + new ModInt(1);
			return tmp;
		}
		public static ModInt operator --(ModInt x)
		{
			var tmp = x - new ModInt(1);
			return tmp;
		}

		public static bool operator >(ModInt l, ModInt r) => l.CompareTo(r) > 0;
		public static bool operator <(ModInt l, ModInt r) => l.CompareTo(r) < 0;
		public static bool operator >=(ModInt l, ModInt r) => l.CompareTo(r) >= 0;
		public static bool operator <=(ModInt l, ModInt r) => l.CompareTo(r) <= 0;
		public static bool operator ==(ModInt l, ModInt r) => l.Equals(r);
		public static bool operator !=(ModInt l, ModInt r) => !l.Equals(r);

		public static implicit operator long(ModInt x) => x.num;
		public static implicit operator ModInt(long n)
		{
			n %= MOD;
			if (n < 0) n += MOD;
			return new ModInt(n);
		}

		public ModInt Inverse() => Inverse(this, MOD);
		public static ModInt Inverse(ModInt x) => Inverse(x.num, MOD);
		public static long Inverse(long x, long m)
		{
			if (x % m == 0) throw new DivideByZeroException();
			long a = x, b = m, u = 1, v = 0;
			while (b > 0)
			{
				long t = a / b;

				a -= t * b;
				long p = a; a = b; b = p;   // swap(a, b);

				u -= t * v;
				p = u; u = v; v = p;        // swap(u, v);
			}
			u %= m;
			if (u < 0) u += m;
			return u;
		}

		public static ModInt Pow(long x, long n)
		{
			long now = 1;
			if (isModPrime) n %= MOD - 1;
			for (; n > 0; n /= 2, x = x * x % MOD)
			{
				if (n % 2 == 1) now = now * x % MOD;
			}
			return new ModInt(now);
		}

		public int CompareTo(ModInt x)
		{
			if (num == x.num) return 0;
			if (num > x.num) return 1;
			return -1;
		}

		public bool Equals(ModInt x) => num == x.num;

		public override bool Equals(object obj) => obj is ModInt m && num == m.num;

		public override int GetHashCode()
		{
			return HashCode.Combine(num);
		}

	}

	static class Util
	{
		public static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
	}

	class Printer : StreamWriter
	{
		public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
		public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
		public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { }
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] separator = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Read() => ReadString();

		public string ReadString()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(separator, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return ReadString();
			i = 0;
			return s[i++];
		}

		public string[] ReadStringArray(int N)
		{
			string[] Array = new string[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadString();
			}
			return Array;
		}

		public int ReadInt()
		{
			return int.Parse(ReadString());
		}

		public int[] ReadIntArray(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadInt() + add;
			}
			return Array;
		}

		public long ReadLong()
		{
			return long.Parse(ReadString());
		}

		public long[] ReadLongArray(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadLong() + add;
			}
			return Array;
		}

		public double ReadDouble()
		{
			return double.Parse(ReadString());
		}

		public double[] ReadDoubleArray(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadDouble() + add;
			}
			return Array;
		}

		public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1));

		public (T1, T2) ReadValue<T1, T2>()
		{
			var inputs = ReadStringArray(2);
			var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
			var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
			return (v1, v2);
		}

		public (T1, T2, T3) ReadValue<T1, T2, T3>()
		{
			var inputs = ReadStringArray(3);
			var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
			var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
			var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
			return (v1, v2, v3);
		}

		public (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>()
		{
			var inputs = ReadStringArray(4);
			var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
			var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
			var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
			var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
			return (v1, v2, v3, v4);
		}

		public (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>()
		{
			var inputs = ReadStringArray(5);
			var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
			var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
			var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
			var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
			var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
			return (v1, v2, v3, v4, v5);
		}

		public (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>()
		{
			var inputs = ReadStringArray(6);
			var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
			var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
			var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
			var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
			var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
			var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));
			return (v1, v2, v3, v4, v5, v6);
		}

		public (T1, T2, T3, T4, T5, T6, T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>()
		{
			var inputs = ReadStringArray(7);
			var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
			var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
			var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
			var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
			var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
			var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));
			var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7));
			return (v1, v2, v3, v4, v5, v6, v7);
		}

		public T1[] ReadValueArray<T1>(int N)
		{
			var v1 = new T1[N];
			for (int i = 0; i < N; i++)
			{
				v1[i] = ReadValue<T1>();
			}
			return v1;
		}

		public (T1[], T2[]) ReadValueArray<T1, T2>(int N)
		{
			var (v1, v2) = (new T1[N], new T2[N]);
			for (int i = 0; i < N; i++)
			{
				var (t1, t2) = ReadValue<T1, T2>();
				v1[i] = t1;
				v2[i] = t2;
			}
			return (v1, v2);
		}

		public (T1[], T2[], T3[]) ReadValueArray<T1, T2, T3>(int N)
		{
			var (v1, v2, v3) = (new T1[N], new T2[N], new T3[N]);
			for (int i = 0; i < N; i++)
			{
				var (t1, t2, t3) = ReadValue<T1, T2, T3>();
				v1[i] = t1;
				v2[i] = t2;
				v3[i] = t3;
			}
			return (v1, v2, v3);
		}

		public (T1[], T2[], T3[], T4[]) ReadValueArray<T1, T2, T3, T4>(int N)
		{
			var (v1, v2, v3, v4) = (new T1[N], new T2[N], new T3[N], new T4[N]);
			for (int i = 0; i < N; i++)
			{
				var (t1, t2, t3, t4) = ReadValue<T1, T2, T3, T4>();
				v1[i] = t1;
				v2[i] = t2;
				v3[i] = t3;
				v4[i] = t4;
			}
			return (v1, v2, v3, v4);
		}

		public (T1[], T2[], T3[], T4[], T5[]) ReadValueArray<T1, T2, T3, T4, T5>(int N)
		{
			var (v1, v2, v3, v4, v5) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N]);
			for (int i = 0; i < N; i++)
			{
				var (t1, t2, t3, t4, t5) = ReadValue<T1, T2, T3, T4, T5>();
				v1[i] = t1;
				v2[i] = t2;
				v3[i] = t3;
				v4[i] = t4;
				v5[i] = t5;
			}
			return (v1, v2, v3, v4, v5);
		}

		public (T1[], T2[], T3[], T4[], T5[], T6[]) ReadValueArray<T1, T2, T3, T4, T5, T6>(int N)
		{
			var (v1, v2, v3, v4, v5, v6) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N]);
			for (int i = 0; i < N; i++)
			{
				var (t1, t2, t3, t4, t5, t6) = ReadValue<T1, T2, T3, T4, T5, T6>();
				v1[i] = t1;
				v2[i] = t2;
				v3[i] = t3;
				v4[i] = t4;
				v5[i] = t5;
				v6[i] = t6;
			}
			return (v1, v2, v3, v4, v5, v6);
		}

		public (T1[], T2[], T3[], T4[], T5[], T6[], T7[]) ReadValueArray<T1, T2, T3, T4, T5, T6, T7>(int N)
		{
			var (v1, v2, v3, v4, v5, v6, v7) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N], new T7[N]);
			for (int i = 0; i < N; i++)
			{
				var (t1, t2, t3, t4, t5, t6, t7) = ReadValue<T1, T2, T3, T4, T5, T6, T7>();
				v1[i] = t1;
				v2[i] = t2;
				v3[i] = t3;
				v4[i] = t4;
				v5[i] = t5;
				v6[i] = t6;
				v7[i] = t7;
			}
			return (v1, v2, v3, v4, v5, v6, v7);
		}
	}
}


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

namespace Artem_and_Array
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static int[] nn;

        private static void Main(string[] args)
        {
            int n = Next();
            nn = new int[n + 2];
            nn[0] = -10000000;
            for (int i = 1; i <= n; i++)
            {
                nn[i] = Next();
            }
            nn[n + 1] = -10000000;

            long count = 0;

            var points = new point[n + 2];
            var q = new Queue<point>();
            for (int i = 1; i <= n; i++)
            {
                var p = new point(i - 1, i + 1, nn[i]);
                points[i] = p;
                if (p.value >= p.current)
                {
                    q.Enqueue(p);
                    p.used = true;
                }
            }

            while (q.Count > 0)
            {
                point p = q.Dequeue();
                count += p.value;

                point p1 = points[p.left];
                point p2 = points[p.right];
                p1.right = p.right;
                p2.left = p.left;
                p1.Recalc();
                p2.Recalc();

                if (p1.value >= p1.current && !p1.used)
                {
                    q.Enqueue(p1);
                    p1.used = true;
                }
                if (p2.value >= p2.current && !p2.used)
                {
                    q.Enqueue(p2);
                    p2.used = true;
                }
            }

            var heap = new MaxBinaryHeapObject(new point(0, 0, 0));
            for (int i = 1; i <= n; i++)
            {
                if (!points[i].used)
                    heap.Add(points[i]);
            }

            while (heap.HeapSize > 2)
            {
                point p = heap.GetMax();
                count += p.value;

                point p1 = points[p.left];
                point p2 = points[p.right];
                p1.right = p.right;
                p2.left = p.left;

                p1.Recalc();
                heap.Heapify(p1);
                p2.Recalc();
                heap.Heapify(p2);
            }

            writer.WriteLine(count);
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }

        #region Nested type: MaxBinaryHeapObject

        public class MaxBinaryHeapObject
        {
            private readonly IComparer<point> _comparer;
            private readonly List<point> _list;

            public MaxBinaryHeapObject(IComparer<point> comparer)
            {
                _comparer = comparer ?? Comparer<point>.Default;
                _list = new List<point>();
            }

            public int HeapSize
            {
                get { return _list.Count; }
            }

            public void Add(point value)
            {
                _list.Add(value);
                value.where = _list.Count - 1;
                MoveUp(HeapSize - 1);
            }

            private void MoveUp(int i)
            {
                int parent = (i - 1)/2;

                while (i > 0 && _comparer.Compare(_list[parent], _list[i]) == -1)
                {
                    point temp = _list[i];
                    _list[i] = _list[parent];
                    _list[parent] = temp;

                    _list[i].where = i;
                    _list[parent].where = parent;

                    i = parent;
                    parent = (i - 1)/2;
                }
            }

            public void Heapify(point t)
            {
                MoveUp(t.where);
                MoveDown(t.where);
            }

            private void MoveDown(int i)
            {
                for (;;)
                {
                    int leftChild = 2*i + 1;
                    int rightChild = 2*i + 2;
                    int largestChild = i;

                    if (leftChild < HeapSize && _comparer.Compare(_list[leftChild], _list[largestChild]) == 1)
                    {
                        largestChild = leftChild;
                    }

                    if (rightChild < HeapSize && _comparer.Compare(_list[rightChild], _list[largestChild]) == 1)
                    {
                        largestChild = rightChild;
                    }

                    if (largestChild == i)
                    {
                        break;
                    }

                    point temp = _list[i];
                    _list[i] = _list[largestChild];
                    _list[largestChild] = temp;

                    _list[i].where = i;
                    _list[largestChild].where = largestChild;

                    i = largestChild;
                }
            }

            public point Max()
            {
                return _list[0];
            }

            public point GetMax()
            {
                point result = _list[0];
                _list[0] = _list[HeapSize - 1];
                _list[0].where = 0;
                _list.RemoveAt(HeapSize - 1);
                MoveDown(0);
                return result;
            }
        }

        #endregion

        #region Nested type: point

        public class point : IComparer<point>
        {
            public readonly int current;
            public int left;
            public int right;
            public bool used;
            public int value;
            public int where;

            public point(int left, int right, int current)
            {
                this.left = left;
                this.right = right;
                this.current = current;
                value = Math.Min(nn[left], nn[right]);
            }

            #region IComparer<point> Members

            public int Compare(point x, point y)
            {
                int c = (x.value).CompareTo(y.value);
                //if (c == 0)
                //    c = y._current.CompareTo(x._current);
                return c;
            }

            #endregion

            public void Recalc()
            {
                value = Math.Min(nn[left], nn[right]);
            }
        }

        #endregion
    }
}


using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    ReadData re;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        re = new ReadData();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        long H = re.l();
        long W = re.l();
        if(H == 1 || W == 1){
            H = Math.Max(H,W);
            long count = H / 6 * 6;
            if(H % 6 == 4){
                count += 2;
            }
            if(H % 6 == 5){
                count += 4;
            }
            sb.Append(count + "\n");
            return;
        }
        if(H >= 3 && W >= 3){
            sb.Append(H*W/2*2+"\n");
            return;
        }
        if(H != 2){
            W = H;
            H = 2;
        }
        if(W == 2){
            sb.Append("0\n");
            return;
        }
        else if(W == 3){
            sb.Append("4\n");
            return;
        }
        else if(W == 7){
            sb.Append("12\n");
            return;
        }
        sb.Append((W*2)+"\n");
    }
}
class PrimeFactor{
    int[] LowestPrimeFactor;
    public int[] Prime;
    int N;
    public PrimeFactor(int N0){
        N = N0;
        N++;
        LowestPrimeFactor = new int[N];
        List<int> prime = new List<int>();
        for(int i=1;i<N;i++){
            LowestPrimeFactor[i] = i;
        }
        for(int i=2;i<N;i++){
            if(LowestPrimeFactor[i] == i){
                prime.Add(i);
            }
            for(int j=0;j<prime.Count;j++){
                if(prime[j]*i < N && prime[j] <= LowestPrimeFactor[i]){
                    LowestPrimeFactor[prime[j]*i] = prime[j];
                }
                else{
                    break;
                }
            }
        }
        Prime = prime.ToArray();
    }
    public int[] PrimeDivide(int X){
        List<int> ans = new List<int>();
        while(X != 1){
            ans.Add(LowestPrimeFactor[X]);
            X /= LowestPrimeFactor[X];
        }
        return ans.ToArray();
    }
    public int[] PrimeDivide(long X0){
        List<int> ans = new List<int>();
        int X = (int)X0;
        int i=0;
        while(X >= N){
            if(X % Prime[i] == 0){
                ans.Add(Prime[i]);
                X /= Prime[i];
            }
            else{
                i++;
                if(i == Prime.Length){
                    ans.Add(X);
                    X = 1;
                }
            }
        }
        while(X != 1){
            ans.Add(LowestPrimeFactor[X]);
            X /= LowestPrimeFactor[X];
        }
        return ans.ToArray();
    }
    public int[] Divisor(int X){
        List<int> ans = new List<int>();
        ans.Add(1);
        while(X != 1){
            int p = LowestPrimeFactor[X];
            int c = 0;
            while(X % p == 0){
                X /= p;
                c++;
            }
            int l = ans.Count;
            int d = p;
            for(int i=1;i<=c;i++){
                for(int j=0;j<l;j++){
                    ans.Add(d*ans[j]);
                }
                d *= p;
            }
        }
        return ans.ToArray();
    }
    public int[] Divisor(long X0){
        List<int> ans = new List<int>();
        int X = (int)X0;
        ans.Add(1);
        int i=0;
        while(X >= N){
            if(X % Prime[i] == 0){
                int p = Prime[i];
                int c = 0;
                while(X % p == 0){
                    X /= p;
                    c++;
                }
                int l = ans.Count;
                int d = p;
                for(int k=1;k<=c;k++){
                    for(int j=0;j<l;j++){
                        ans.Add(d*ans[j]);
                    }
                    d *= p;
                }
            }
            else{
                i++;
                if(i == Prime.Length){
                    int l = ans.Count;
                    for(int j=0;j<l;j++){
                        ans.Add(X*ans[j]);
                    }
                    X = 1;
                }
            }
        }
        while(X != 1){
            int p = LowestPrimeFactor[X];
            int c = 0;
            while(X % p == 0){
                X /= p;
                c++;
            }
            int l = ans.Count;
            int d = p;
            for(int k=1;k<=c;k++){
                for(int j=0;j<l;j++){
                    ans.Add(d*ans[j]);
                }
                d *= p;
            }
        }
        return ans.ToArray();
    }
    public int Phi(int X){
        int ans = X;
        while(X != 1){
            int p = LowestPrimeFactor[X];
            while(X % p == 0){
                X /= p;
            }
            ans /= p;
            ans *= p-1;
        }
        return ans;
    }
    public int Phi(long X0){
        int ans = (int)X0;
        int X = (int)X0;
        int i=0;
        while(X >= N){
            if(X % Prime[i] == 0){
                int p = Prime[i];
                while(X % p == 0){
                    X /= p;
                }
                ans /= p;
                ans *= p-1;
            }
            else{
                i++;
                if(i == Prime.Length){
                    int p = X;
                    ans /= p;
                    ans *= p-1;
                    X = 1;
                }
            }
        }
        while(X != 1){
            int p = LowestPrimeFactor[X];
            while(X % p == 0){
                X /= p;
            }
            ans /= p;
            ans *= p-1;
        }
        return ans;
    }
}
class ReadData{
    string[] str;
    int counter;
    public ReadData(){
        counter = 0;
    }
    public string s(){
        if(counter == 0){
            str = Console.ReadLine().Split(' ');
            counter = str.Length;
        }
        counter--;
        return str[str.Length-counter-1];
    }
    public int i(){
        return int.Parse(s());
    }
    public long l(){
        return long.Parse(s());
    }
    public double d(){
        return double.Parse(s());
    }
    public int[] ia(int N){
        int[] ans = new int[N];
        for(int j=0;j<N;j++){
            ans[j] = i();
        }
        return ans;
    }
    public int[] ia(){
        str = Console.ReadLine().Split(' ');
        counter = 0;
        int[] ans = new int[str.Length];
        for(int j=0;j<str.Length;j++){
            ans[j] = int.Parse(str[j]);
        }
        return ans;
    }
    public long[] la(int N){
        long[] ans = new long[N];
        for(int j=0;j<N;j++){
            ans[j] = l();
        }
        return ans;
    }
    public long[] la(){
        str = Console.ReadLine().Split(' ');
        counter = 0;
        long[] ans = new long[str.Length];
        for(int j=0;j<str.Length;j++){
            ans[j] = long.Parse(str[j]);
        }
        return ans;
    }
    public double[] da(int N){
        double[] ans = new double[N];
        for(int j=0;j<N;j++){
            ans[j] = d();
        }
        return ans;
    }
    public double[] da(){
        str = Console.ReadLine().Split(' ');
        counter = 0;
        double[] ans = new double[str.Length];
        for(int j=0;j<str.Length;j++){
            ans[j] = double.Parse(str[j]);
        }
        return ans;
    }
    public List<int>[] g(int N,int[] f,int[] t){
        List<int>[] ans = new List<int>[N];
        for(int j=0;j<N;j++){
            ans[j] = new List<int>();
        }
        for(int j=0;j<f.Length;j++){
            ans[f[j]].Add(t[j]);
            ans[t[j]].Add(f[j]);
        }
        return ans;
    }
    public List<int>[] g(int N,int M){
        List<int>[] ans = new List<int>[N];
        for(int j=0;j<N;j++){
            ans[j] = new List<int>();
        }
        for(int j=0;j<M;j++){
            int f = i()-1;
            int t = i()-1;
            ans[f].Add(t);
            ans[t].Add(f);
        }
        return ans;
    }
    public List<int>[] g(){
        int N = i();
        int M = i();
        List<int>[] ans = new List<int>[N];
        for(int j=0;j<N;j++){
            ans[j] = new List<int>();
        }
        for(int j=0;j<M;j++){
            int f = i()-1;
            int t = i()-1;
            ans[f].Add(t);
            ans[t].Add(f);
        }
        return ans;
    }
}
public static class Define{
    public const long mod = 1000000007;
}
public static class Debug{
    public static void Print(double[,,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                for(int l=0;l<k.GetLength(2);l++){
                    Console.Write(k[i,j,l]+" ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
    public static void Print(double[,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                Console.Write(k[i,j]+" ");
            }
            Console.WriteLine();
        }
    }
    public static void Print(double[] k){
        for(int i=0;i<k.Length;i++){
            Console.WriteLine(k[i]);
        }
    }
    public static void Print(long[,,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                for(int l=0;l<k.GetLength(2);l++){
                    Console.Write(k[i,j,l]+" ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
    public static void Print(long[,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                Console.Write(k[i,j]+" ");
            }
            Console.WriteLine();
        }
    }
    public static void Print(long[] k){
        for(int i=0;i<k.Length;i++){
            Console.WriteLine(k[i]);
        }
    }
    public static void Print(int[,,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                for(int l=0;l<k.GetLength(2);l++){
                    Console.Write(k[i,j,l]+" ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
    public static void Print(int[,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                Console.Write(k[i,j]+" ");
            }
            Console.WriteLine();
        }
    }
    public static void Print(int[] k){
        for(int i=0;i<k.Length;i++){
            Console.WriteLine(k[i]);
        }
    }
}


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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solution
{
    const int MAXN = 50;
    const int MAX_INV = MAXN * MAXN;

    long Fun(int n, int mod)
    {
        var d = new long[MAX_INV];
        d[0] = 1;
        int max = 0;
        long ans = 0;
        for (int i = 1; i < n; i++)
        {
            var nd = new long[MAX_INV];
            int nmax = max;
            long sum = 0;
            for (int j = 0; j <= i; j++)
                for (int k = 0; k <= i; k++)
                {
                    for (int p = 0; p <= max; p++)
                    {
                        int o = p + j - k;
                        nmax = Math.Max(nmax, o);
                        if (o >= 0)
                        {
                            nd[o] = (nd[o] + d[p]) % mod;
                            if (j < k && o > 0)
                                sum = (sum + d[p]) % mod;
                        }
                        if (p == 0)
                            continue;
                        o = -p + j - k;
                        nmax = Math.Max(nmax, o);
                        if (o >= 0)
                        {
                            nd[o] = (nd[o] + d[p]) % mod;
                            if (j < k && o > 0)
                                sum = (sum + d[p]) % mod;
                        }
                    }
                }
            ans = ((i + 1) * ans + sum) % mod;
            max = nmax;
            d = nd;
        }

        return ans;
    }

    public void Solve()
    {
        int n = ReadInt();
        int mod = ReadInt();

        Write(Fun(n, mod));
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUGLOCAL
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("ysys.in");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            new Solution().Solve();
            //var thread = new Thread(new Solution().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
        }
        catch (Exception ex)
        {
#if DEBUGLOCAL
            Console.WriteLine(ex);
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }
        return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array) writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }
    #endregion
}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.106
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tech1", "Tech1\Tech1.csproj", "{1EB1A4F0-0118-4CCD-BF17-D608A682C2B4}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{1EB1A4F0-0118-4CCD-BF17-D608A682C2B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{1EB1A4F0-0118-4CCD-BF17-D608A682C2B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{1EB1A4F0-0118-4CCD-BF17-D608A682C2B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{1EB1A4F0-0118-4CCD-BF17-D608A682C2B4}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {C3620269-6E19-4EA1-ABB1-CD478D85838E}
	EndGlobalSection
EndGlobal


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

namespace Task1
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var len = str.Length;
            if (len == 1)
            {
                Console.WriteLine(str);
            }
            else {
                int[] ind = new int[len];
                int maxodd = (len % 2 == 0) ? len - 1 : len;
                for (int i = 0; i < len / 2; i++)
                {
                    ind[i] = maxodd - 2 * i;
                }
                for (int i = len / 2; i < len; i++)
                {
                    ind[i] = 2 + (i - len / 2) * 2;
                }
                var res = new List<char>(str);

                for (int i = 0; i < len; i++)
                {
                    res[ind[i] - 1] = str[i];
                }
                Console.WriteLine(String.Join("", res));
            }
            //TODO: comment before sending
            //Console.WriteLine("Done...");
            //Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		int N = str.Length;
		string ans = "";
		if(N%2==0){
			for(var i=0;i<N/2;i++){
				ans += str.Substring(N/2-1-i,1);
				ans += str.Substring(N/2+i,1);
			}
		} else {
			ans += str.Substring((N-1)/2,1);
			for(var i=1;i<=(N-1)/2;i++){
				ans += str.Substring((N-1)/2+i,1);
				ans += str.Substring((N-1)/2-i,1);
			}
		}
		Console.WriteLine(ans);
	}
}


using System;

namespace CSharp
{
    class _1085A
    {
        public static void Main()
        {
            string t = Console.ReadLine();

            var s = new char[t.Length];
            for (int i = 0; i < t.Length; i++)
            {
                s[i] = t[(t.Length - 1) / 2 + Math.Sign(i % 2 - 0.5) * ((i + 1) / 2)];
            }

            Console.WriteLine(new string(s));
        }
    }
}


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

namespace Codeforces.R355.D
{
    public static class Solver
    {
        public static void Main()
        {
            using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Solve(Console.In, sw);
            }
        }

        public static void Solve(TextReader tr, TextWriter tw)
        {
            WriteAnswer(tw, Parse(tr));
        }

        struct Answer
        {
            public string Winner;
        }

        private static void WriteAnswer(TextWriter tw, Answer answer)
        {
            tw.WriteLine(answer.Winner);
        }

        private static Answer Parse(TextReader tr)
        {
            var n = int.Parse(tr.ReadLine());
            var board = new string[n];
            for (var i = 0; i < n; ++i)
                board[i] = tr.ReadLine();
            return Calc(board);
        }

        private static Answer Calc(string[] board)
        {
            var answer = new Answer();
            var memo = new Dictionary<string, int>();
            var r = Rec("" + board[0][0], 0, 0, board, memo);

            if (r > 0)
                answer.Winner = "FIRST";
            else if (r < 0)
                answer.Winner = "SECOND";
            else
                answer.Winner = "DRAW";

            return answer;
        }

        private static int Rec(string str, int currentR, int currentC, string[] board, Dictionary<string, int> memo)
        {
            if (memo.ContainsKey(str))
                return memo[str];

            var n = board.Length;
            var numStr = str.Length;

            if (numStr == n * 2 - 1)
            {
                return str.Count(c => c == 'a') - str.Count(c => c == 'b');
            }

            var res = numStr % 2 == 0 ? int.MinValue : int.MaxValue;

            if (currentR + 1 < n)
            {
                var r = currentR + 1;
                var c = currentC;

                if (numStr % 2 == 0)
                    res = Math.Max(res, Rec(str + board[r][c], r, c, board, memo));
                else
                    res = Math.Min(res, Rec(str + board[r][c], r, c, board, memo));
            }
            if (currentC + 1 < n)
            {
                var r = currentR;
                var c = currentC + 1;

                if (numStr % 2 == 0)
                    res = Math.Max(res, Rec(str + board[r][c], r, c, board, memo));
                else
                    res = Math.Min(res, Rec(str + board[r][c], r, c, board, memo));
            }
            return memo[str] = res;
        }
    }
}


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

namespace Codeforces
{
    internal static class Program
    {
        private const string test = "D1";

        private static void Solve()
        {
            int n,k;
            Read(out n, out k);
            long res = k-1;
            var mod = 1000000007;
            for (int i = 1; i <= k-1; i++)
            {
                res *= k;
                res %= mod;
            }
            for (int i = 1; i <= n-k; i++)
            {
                res *= n-k;
                res %= mod;
            }
            WriteLine(res);
        }

        private static void Main()
        {
            if (Debugger.IsAttached)
            {
                Console.SetIn(new StreamReader(String.Format(@"..\..\..\..\Tests\{0}.in", test)));
            }

            Solve();

            if (Debugger.IsAttached)
            {
                Console.In.Close();
                Console.SetIn(new StreamReader(Console.OpenStandardInput()));
                Console.ReadLine();
            }
        }

        private static int[] SortIndexs<T>(this IEnumerable<T> source) where T : IComparable
        {
            var array = source == null ? new List<T>() : source.ToList();
            var n = array.Count;
            var res = Enumerable.Range(0, n).ToArray();
            Array.Sort(res, (a, b) => array[a].CompareTo(array[b]));
            return res;
        }

        #region Reader

        private static string Read()
        {
            return Console.ReadLine();
        }

        private static void Read<T>(out T a1, out T a2)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3, out T a4)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
            a4 = (T)Convert.ChangeType(input[3], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3, out T a4, out T a5)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
            a4 = (T)Convert.ChangeType(input[3], typeof(T));
            a5 = (T)Convert.ChangeType(input[4], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3, out T a4, out T a5, out T a6)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
            a4 = (T)Convert.ChangeType(input[3], typeof(T));
            a5 = (T)Convert.ChangeType(input[4], typeof(T));
            a6 = (T)Convert.ChangeType(input[5], typeof(T));
        }

        private static int ReadInt()
        {
            return Int32.Parse(Read());
        }

        private static long ReadLong()
        {
            return long.Parse(Read());
        }

        private static double ReadDouble()
        {
            return double.Parse(Read(), CultureInfo.InvariantCulture);
        }

        private static T Read<T>()
        {
            return (T)Convert.ChangeType(Read(), typeof(T));
        }

        private static string[] ReadArray()
        {
            var readLine = Console.ReadLine();
            if (readLine != null)
                return readLine.Split(' ');

            throw new ArgumentException();
        }

        private static List<int> ReadIntArray()
        {
            return ReadArray().Select(Int32.Parse).ToList();
        }

        private static List<long> ReadLongArray()
        {
            return ReadArray().Select(long.Parse).ToList();
        }

        private static List<double> ReadDoubleArray()
        {
            return ReadArray().Select(d => double.Parse(d, CultureInfo.InvariantCulture)).ToList();
        }

        private static List<T> ReadArray<T>()
        {
            return ReadArray().Select(x => (T)Convert.ChangeType(x, typeof(T))).ToList();
        }

        private static void WriteLine(double value)
        {
            Console.WriteLine(value.ToString(CultureInfo.InvariantCulture));
        }

        private static void WriteLine(double value, string stringFormat)
        {
            Console.WriteLine(value.ToString(stringFormat, CultureInfo.InvariantCulture));
        }

        private static void WriteLine<T>(T value)
        {
            Console.WriteLine(value);
        }

        private static void Write(double value)
        {
            Console.Write(value.ToString(CultureInfo.InvariantCulture));
        }

        private static void Write(double value, string stringFormat)
        {
            Console.Write(value.ToString(stringFormat, CultureInfo.InvariantCulture));
        }

        private static void Write<T>(T value)
        {
            Console.Write(value);
        }

        #endregion
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;

namespace Codeforces
{
    class B
    {
        private static ThreadStart s_threadStart = new B().Go;
        private static bool s_time = false;

        private void Go()
        {
            long mod = 1000000007;
            long N = GetInt();
            long n = GetInt();

            long[,] bin = new long[n + 1, n + 1];
            long[,] pow = new long[n + 1, n + 1];
            bin[0, 0] = 1; bin[1, 0] = 1; bin[1, 1] = 1;
            for (int i = 2; i <= n; i++)
            {
                bin[i, 0] = 1; bin[i, i] = 1;
                for (int j = 1; j < i; j++)
                {
                    bin[i, j] = (bin[i - 1, j - 1] + bin[i - 1, j]) % mod;
                    pow[i, j] = (pow[i, j - 1] * i) % mod;
                }
            }

            for (int i = 0; i <= n; i++)
            {
                pow[i, 0] = 1;
                for (int j = 1; j <= n; j++)
                {
                    pow[i, j] = (pow[i, j - 1] * i) % mod;
                }
            }

            long[,] dp = new long[n + 1, n + 1];
            dp[1, 1] = 1;

            for (int nn = 2; nn <= n; nn++)
            {
                for (int l = 1; l < nn; l++)
                {
                    long sum = 0;
                    for (int i = 1; i <= nn-l; i++)
                    {
                        sum = (sum + (dp[nn - l, i] * pow[i, l]) % mod) % mod;
                    }
                    dp[nn,l] = (bin[nn,l] * sum) % mod;
                }
                dp[nn, nn]= 1;
            }

            long res = 0;
            if (n == 1) res = 1;
            else
            {
                for (int i = 1; i < n; i++)
                {
                    res = (res + dp[n - 1, i]) % mod;
                }
            }

            res = (res * n) % mod;

            for (int i = 0; i < N-n; i++)
            {
                res = (res * (N - n)) % mod;
            }

            Wl(res);
        }

        #region Template

        public static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            Thread main = new Thread(new ThreadStart(s_threadStart), 200 * 1024 * 1024);
            timer.Start();
            main.Start();
            main.Join();
            timer.Stop();
            if (s_time)
                Wl(timer.ElapsedMilliseconds);
        }

        private static IEnumerator<string> ioEnum;
        private static string GetString()
        {
            while (ioEnum == null || !ioEnum.MoveNext())
            {
                ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();
            }

            return ioEnum.Current;
        }

        private static int GetInt()
        {
            return int.Parse(GetString());
        }

        private static long GetLong()
        {
            return long.Parse(GetString());
        }

        private static double GetDouble()
        {
            return double.Parse(GetString());
        }

        private static List<int> GetIntArr(int n)
        {
            List<int> ret = new List<int>(n);
            for (int i = 0; i < n; i++)
            {
                ret.Add(GetInt());
            }
            return ret;
        }

        private static void Wl<T>(T o)
        {
            if (o is double)
            {
                Wld((o as double?).Value, "");
            }
            else if (o is float)
            {
                Wld((o as float?).Value, "");
            }
            else
                Console.WriteLine(o.ToString());
        }

        private static void Wl<T>(IEnumerable<T> enumerable)
        {
            Wl(string.Join(" ", enumerable.Select(e => e.ToString()).ToArray()));
        }

        private static void Wld(double d, string format)
        {
            Wl(d.ToString(format, CultureInfo.InvariantCulture));
        }

        public struct Tuple<T, K> : IComparable<Tuple<T, K>>
            where T : IComparable<T>
            where K : IComparable<K>
        {
            public T Item1;
            public K Item2;

            public Tuple(T t, K k)
            {
                Item1 = t;
                Item2 = k;
            }

            public override bool Equals(object obj)
            {
                var o = (Tuple<T, K>)obj;
                return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);
            }

            public override int GetHashCode()
            {
                return Item1.GetHashCode() ^ Item2.GetHashCode();
            }

            public override string ToString()
            {
                return "(" + Item1 + " " + Item2 + ")";
            }

            #region IComparable<Tuple<T,K>> Members

            public int CompareTo(Tuple<T, K> other)
            {
                int ret = Item1.CompareTo(other.Item1);
                if (ret != 0) return ret;
                return Item2.CompareTo(other.Item2);
            }

            #endregion
        }

        #endregion
    }
}


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

namespace Codeforces
{
    internal static class Program
    {
        private const string test = "D1";

        private static void Solve()
        {
            int n,k;
            Read(out n, out k);
            long res = 1;
            var mod = 1000000007;
            for (int i = 1; i <= k-1; i++)
            {
                res *= k;
                res %= mod;
            }
            for (int i = 1; i <= n-k; i++)
            {
                res *= n-k;
                res %= mod;
            }
            WriteLine(res);
        }

        private static void Main()
        {
            if (Debugger.IsAttached)
            {
                Console.SetIn(new StreamReader(String.Format(@"..\..\..\..\Tests\{0}.in", test)));
            }

            Solve();

            if (Debugger.IsAttached)
            {
                Console.In.Close();
                Console.SetIn(new StreamReader(Console.OpenStandardInput()));
                Console.ReadLine();
            }
        }

        private static int[] SortIndexs<T>(this IEnumerable<T> source) where T : IComparable
        {
            var array = source == null ? new List<T>() : source.ToList();
            var n = array.Count;
            var res = Enumerable.Range(0, n).ToArray();
            Array.Sort(res, (a, b) => array[a].CompareTo(array[b]));
            return res;
        }

        #region Reader

        private static string Read()
        {
            return Console.ReadLine();
        }

        private static void Read<T>(out T a1, out T a2)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3, out T a4)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
            a4 = (T)Convert.ChangeType(input[3], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3, out T a4, out T a5)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
            a4 = (T)Convert.ChangeType(input[3], typeof(T));
            a5 = (T)Convert.ChangeType(input[4], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3, out T a4, out T a5, out T a6)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
            a4 = (T)Convert.ChangeType(input[3], typeof(T));
            a5 = (T)Convert.ChangeType(input[4], typeof(T));
            a6 = (T)Convert.ChangeType(input[5], typeof(T));
        }

        private static int ReadInt()
        {
            return Int32.Parse(Read());
        }

        private static long ReadLong()
        {
            return long.Parse(Read());
        }

        private static double ReadDouble()
        {
            return double.Parse(Read(), CultureInfo.InvariantCulture);
        }

        private static T Read<T>()
        {
            return (T)Convert.ChangeType(Read(), typeof(T));
        }

        private static string[] ReadArray()
        {
            var readLine = Console.ReadLine();
            if (readLine != null)
                return readLine.Split(' ');

            throw new ArgumentException();
        }

        private static List<int> ReadIntArray()
        {
            return ReadArray().Select(Int32.Parse).ToList();
        }

        private static List<long> ReadLongArray()
        {
            return ReadArray().Select(long.Parse).ToList();
        }

        private static List<double> ReadDoubleArray()
        {
            return ReadArray().Select(d => double.Parse(d, CultureInfo.InvariantCulture)).ToList();
        }

        private static List<T> ReadArray<T>()
        {
            return ReadArray().Select(x => (T)Convert.ChangeType(x, typeof(T))).ToList();
        }

        private static void WriteLine(double value)
        {
            Console.WriteLine(value.ToString(CultureInfo.InvariantCulture));
        }

        private static void WriteLine(double value, string stringFormat)
        {
            Console.WriteLine(value.ToString(stringFormat, CultureInfo.InvariantCulture));
        }

        private static void WriteLine<T>(T value)
        {
            Console.WriteLine(value);
        }

        private static void Write(double value)
        {
            Console.Write(value.ToString(CultureInfo.InvariantCulture));
        }

        private static void Write(double value, string stringFormat)
        {
            Console.Write(value.ToString(stringFormat, CultureInfo.InvariantCulture));
        }

        private static void Write<T>(T value)
        {
            Console.Write(value);
        }

        #endregion
    }
}


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

namespace Task
{

    #region MyIo

    internal class MyIo : IDisposable
    {
        private readonly TextReader inputStream;
        private readonly TextWriter outputStream = Console.Out;

        private string[] tokens;
        private int pointer;

        public MyIo()
#if  LOCAL_TEST
            : this(new StreamReader("input.txt"))
#else
            : this(System.Console.In)
#endif
        {

        }

        public MyIo(TextReader inputStream)
        {
            this.inputStream = inputStream;
        }

        public string NextLine()
        {
            try
            {
                return inputStream.ReadLine();
            }
            catch (IOException)
            {
                return null;
            }
        }

        public string NextString()
        {
            try
            {
                while (tokens == null || pointer >= tokens.Length)
                {
                    tokens = NextLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    pointer = 0;
                }
                return tokens[pointer++];
            }
            catch (IOException)
            {
                return null;
            }
        }

        public int NextInt()
        {
            return Next<int>();
        }

        public long NextLong()
        {
            return Next<long>();
        }

        public T Next<T>()
        {
            return (T)Convert.ChangeType(NextString(), typeof(T));
        }

        public IEnumerable<T> NextSeq<T>(int n)
        {
            for (int i = 0; i < n; i++)
                yield return Next<T>();
        }

        public void Print(string format, params object[] args)
        {
            outputStream.Write(string.Format(CultureInfo.InvariantCulture, format, args));
        }

        public void PrintLine(string format, params object[] args)
        {
            Print(format, args);

            outputStream.WriteLine();
        }

        public void Print(bool o)
        {
            Print(o ? "YES" : "NO");
        }

        public void PrintLine(bool o)
        {
            PrintLine(o ? "YES" : "NO");
        }

        public void Print<T>(T o)
        {
            outputStream.Write(o);
        }

        public void PrintLine<T>(T o)
        {
            outputStream.WriteLine(o);
        }

        public void Close()
        {
            inputStream.Close();
            outputStream.Close();
        }

        void IDisposable.Dispose()
        {
            Close();

#if  LOCAL_TEST
            Console.ReadLine();
#endif
        }
    }

    public static class ListExtensions
    {
        public static T CycleGet<T>(this IList<T> self, int index)
        {
            return self[index % self.Count];
        }

        public static IList<T> Shuffle<T>(this IList<T> self)
        {
            var rnd = new Random(DateTime.Now.Millisecond);

            var n = self.Count;

            while (n > 1)
            {
                n--;
                var k = rnd.Next(n + 1);
                var value = self[k];
                self[k] = self[n];
                self[n] = value;
            }

            return self;
        }

        public static IList<T> Fill<T>(this IList<T> self, T val)
        {
            for (int i = 0; i < self.Count; i++)
            {
                self[i] = val;
            }

            return self;
        }
    }

    public static class P
    {
        public static P<T1, T2> Create<T1, T2>(T1 key, T2 val)
        {
            return new P<T1, T2>(key, val);
        }
    }

    public class P<T1, T2>
    {
        private class PComparer : IComparer<P<T1, T2>>
        {
            private readonly bool? byKey;

            public PComparer(bool? byKey)
            {
                this.byKey = byKey;
            }

            public int Compare(P<T1, T2> x, P<T1, T2> y)
            {
                x = x ?? new P<T1, T2>();
                y = y ?? new P<T1, T2>();

                if (byKey == true)
                    return Comparer<T1>.Default.Compare(x.Key, y.Key);
                else if (byKey == false)
                    return Comparer<T2>.Default.Compare(x.Value, y.Value);
                else
                {
                    var tr = Comparer<T1>.Default.Compare(x.Key, y.Key);

                    if (tr != 0)
                        tr = Comparer<T2>.Default.Compare(x.Value, y.Value);

                    return tr;
                }
            }
        }

        public P()
        {
        }

        public P(T1 key, T2 val)
        {
            this.Key = key;
            this.Value = val;
        }

        public T1 Key
        {
            get;
            set;
        }

        public T2 Value
        {
            get;
            set;
        }

        public P<T1, T2> Clone()
        {
            return new P<T1, T2>(Key, Value);
        }

        public static IComparer<P<T1, T2>> KeyComparer
        {
            get { return new PComparer(true); }
        }

        public static IComparer<P<T1, T2>> ValueComparer
        {
            get { return new PComparer(false); }
        }

        public static implicit operator T1(P<T1, T2> obj)
        {
            return obj.Key;
        }

        public static implicit operator T2(P<T1, T2> obj)
        {
            return obj.Value;
        }

        public P<T1, T2> SetKey(T1 key)
        {
            Key = key;
            return this;
        }

        public P<T1, T2> SetValue(T2 value)
        {
            Value = value;
            return this;
        }

        public override string ToString()
        {
            return string.Format("Key: {0}, Value: {1}", Key, Value);
        }

        public override int GetHashCode()
        {
            int hash = 17;
            hash = hash * 31 + ((Equals(Key, default(T1))) ? 0 : Key.GetHashCode());
            hash = hash * 31 + ((Equals(Value, default(T1))) ? 0 : Key.GetHashCode());
            return hash;

        }
    }

    #endregion

    internal class Program
    {
        #region Program

        private readonly MyIo io;

        public Program(MyIo io)
        {
            this.io = io;
        }

        public static void Main(string[] args)
        {
            using (MyIo io = new MyIo())
            {
                new Program(io)
                    .Solve();
            }
        }

        #endregion
        public const long MOD = 1000000007;
        public const double EPS = 1e-14;

        private void Solve()
        {
            var a = io.NextInt();
            var b = io.NextInt();

            var sa = io.NextSeq<int>(a).Select(x => x - 1).ToArray();
            var isb = new int[1000000];

            isb.Fill(-1);

            for (int i = 0; i < b; i++)
                isb[io.NextInt() - 1] = i;

            var res = 0;

            long[] q = new long[2 * a];

            for (int i = 0, j = 0; j < 2 * a; ++j)
            {
                q[j] = isb[sa.CycleGet(j)];

                if (q[j] == -1)
                {
                    i = j + 1;
                    continue;
                }

                if (j > 0 && q[j] < q[j - 1])
                {
                    long cycles = (q[j - 1] - q[j] + b - 1) / b;
                    q[j] += cycles * b;
                }

                while (i <= j && q[j] - q[i] >= b || j - i + 1 > a)
                {
                    i++;
                }
                res = Math.Max(res, j - i + 1);
            }

            io.PrintLine(res);
        }
    }

}


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

namespace ConsoleApplication1A
{
  class Program749B
  {
    static void Main(string[] args)
    {

      string[] tk = Console.ReadLine().Split(' ');
      int x1 = Convert.ToInt32(tk[0]);
      int y1 = Convert.ToInt32(tk[1]);
      tk = Console.ReadLine().Split(' ');
      int x2 = Convert.ToInt32(tk[0]);
      int y2 = Convert.ToInt32(tk[1]);
      tk = Console.ReadLine().Split(' ');
      int x3 = Convert.ToInt32(tk[0]);
      int y3 = Convert.ToInt32(tk[1]);

      Console.WriteLine(3);
      Console.WriteLine((x3 - (x2-x1)) + " " + (y3 - (y2-y1)));
      Console.WriteLine((x2 - (x1 - x3)) + " " + (y2 - (y1 - y3)));
      Console.WriteLine((x1 - (x3 - x2)) + " " + (y1 - (y3 - y2)));
    }
  }
}


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

namespace A
{
    class Program
    {
        static Func<string, int> Int = x => int.Parse(x);
        static void Main(string[] args)
        {
            string[] buf = Console.ReadLine().Split(' ');
            int x1 = Int(buf[0]);
            int y1 = Int(buf[1]);
            buf = Console.ReadLine().Split(' ');
            int x2 = Int(buf[0]);
            int y2 = Int(buf[1]);
            buf = Console.ReadLine().Split(' ');
            int x3 = Int(buf[0]);
            int y3 = Int(buf[1]);
            Console.WriteLine(3);
            Console.WriteLine((x1 + x2 - x3) + " " + (y1 + y2 - y3));
            Console.WriteLine((x3 + x2 - x1) + " " + (y3 + y2 - y1));
            Console.WriteLine((x1 + x3 - x2) + " " + (y1 + y3 - y2));
            Console.ReadLine();
        }
    }
}


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

namespace ConsoleApplication
{
    public class Program
    {
        private static void AddPoint(HashSet<Tuple<int, int>> h, Tuple<int, int> a, Tuple<int, int> b, Tuple<int, int> c)
        {
            int y = b.Item2 - a.Item2;
            int x = b.Item1 - a.Item1;

            h.Add(Tuple.Create(c.Item1 + x, c.Item2 + y));
            h.Add(Tuple.Create(c.Item1 - x, c.Item2 - y));
        }

        public static void Main(string[] args)
        {
            Func<int[]> f = () => Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Func<Func<int[]>, Tuple<int, int>> t = x =>
            {
                var r = x();
                return Tuple.Create(r[0], r[1]);
            };

            var a = t(f);
            var b = t(f);
            var c = t(f);

            var h = new HashSet<Tuple<int, int>>();
            AddPoint(h, a, b, c);
            AddPoint(h, b, c, a);
            AddPoint(h, c, a, b);

            Console.WriteLine(h.Count);
            foreach (var p in h)
                Console.WriteLine(string.Format("{0} {1}", p.Item1, p.Item2));
        }
    }
}


using System;
using System.ComponentModel;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

// TODO: Format doubles to use "." instead of "," (locale specific).

public static partial class Program
{
	public static void InputProcessing()
	{
		int[][] points = ParseMatrix<int>(3);
		DataProcessing(points);
	}

	public static void DataProcessing(int[][] points)
	{
		Console.WriteLine(3);
		int[] p1 = points[0];
		int[] p2 = points[1];
		int[] p3 = points[2];
		Foo(p1, p2, p3);
		Foo(p2, p3, p1);
		Foo(p3, p1, p2);
	}

	public static void Foo(int[] p1, int[] p2, int[] p3)
	{
		int x = (p1[0] - p2[0]) + p3[0];
		int y = (p1[1] - p2[1]) + p3[1];
		Console.WriteLine(x + " " + y);
	}
}

public static partial class Program
{
	public static void Main(string[] args)
	{
		InputProcessing();
#if DEBUG
		Console.ReadLine();
#endif
	}

	public static T[] ParseArray<T>()
	{
		TypeConverter tc = TypeDescriptor.GetConverter(typeof(T));
		string[] input = Console.ReadLine().Split();
		T[] output = new T[input.Length];
		for (int i = 0; i < input.Length; i++) { output[i] = (T)tc.ConvertFromString(input[i]); }
		return output;
	}

	public static T[][] ParseMatrix<T>(int nrows)
	{
		T[][] rv = new T[nrows][];
		for (int i = 0; i < nrows; i++) { rv[i] = ParseArray<T>(); }
		return rv;
	}
}


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

public class Solver
{
    #region I/O
    protected static TextReader reader;
    protected static TextWriter writer;

    static void Main()
    {
        #if ONLINE_JUDGE
        reader = Console.In;
        writer = Console.Out;
        #else
        reader = new StreamReader("..\\..\\input.txt");
        writer = new StreamWriter("..\\..\\output.txt");
        #endif
        Solver solver = new Solver();

        try
        {
            object result = solver.Solve();
            if (result != null)
            {
                writer.WriteLine(result);
                Console.Error.WriteLine(result);
            }
        }
        catch (Exception ex)
        {
            Console.Error.WriteLine(ex);
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read helpers

    static Queue<string> currentLineTokens = new Queue<string>();

    public static string ReadToken()
    {
        if (currentLineTokens.Count == 0)
        {
            currentLineTokens = new Queue<string>(reader.ReadLine().Trim().Split(' '));
        }
        return currentLineTokens.Dequeue();
    }

    public static string[] ReadTokens(bool fromCurrentLine = false)
    {
        string[] split;
        if (fromCurrentLine)
        {
            if (currentLineTokens.Count == 0)
                return new string[0];
            split = currentLineTokens.ToArray();
            currentLineTokens.Clear();
        }
        else
        {
            split = reader.ReadLine().Trim().Split(' ');
        }
        return split;
    }

    public static int ReadInt()
    {
        return int.Parse(ReadToken());
    }

    public static long ReadLong()
    {
        return long.Parse(ReadToken());
    }

    public static double ReadDouble()
    {
        return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
    }

    public static int[] ReadIntArray(bool fromCurrentLine = false)
    {
        string[] tokens = ReadTokens(fromCurrentLine);
        return tokens.Select(int.Parse).ToArray();
    }

    public static long[] ReadLongArray(bool fromCurrentLine = false)
    {
        string[] tokens = ReadTokens(fromCurrentLine);
        return tokens.Select(long.Parse).ToArray();
    }

    public static double[] ReadDoubleArray(bool fromCurrentLine = false)
    {
        string[] tokens = ReadTokens(fromCurrentLine);
        return tokens.Select(double.Parse).ToArray();
    }

    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
        {
            lines[i] = reader.ReadLine().Trim();
        }
        return lines;
    }

    #endregion

    public object Solve()
    {
        int TUX = ReadInt();
        int FOO=0;
        int BAR=0;
        int BAZ=0;
        int QUZ=1;
        for (int i = 0; i < TUX; i++)
        {
            int PUR = ReadInt();
            FOO = (FOO + PUR);
            BAR = (BAR + 1);
            if (FOO * QUZ >= BAR * BAZ)
            {
                BAZ = FOO;
                QUZ = BAR;
            }
        }
        return 1.0 * BAZ / QUZ;

    }
}


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

namespace CodeForces
{
    class Prob290C
    {
        //HAI
        //I HAS A TUX
        //GIMMEH TUX
        //I HAS A FOO ITS 0
        //I HAS A BAR ITS 0
        //I HAS A BAZ ITS 0
        //I HAS A QUZ ITS 1
        //TUX IS NOW A NUMBR
        //IM IN YR LOOP NERFIN YR TUX TIL BOTH SAEM TUX AN 0
        //I HAS A PUR
        //GIMMEH PUR
        //PUR IS NOW A NUMBR
        //FOO R SUM OF FOO AN PUR
        //BAR R SUM OF BAR AN 1
        //BOTH SAEM BIGGR OF PRODUKT OF FOO AN QUZ AN PRODUKT OF BAR BAZ AN PRODUKT OF FOO AN QUZ
        //O RLY?
        //YA RLY
        //BAZ R FOO
        //QUZ R BAR
        //OIC
        //IM OUTTA YR LOOP
        //BAZ IS NOW A NUMBAR
        //VISIBLE SMOOSH QUOSHUNT OF BAZ QUZ
        //KTHXBYE

        int totalNums; //total number of input numbers
        int[] numbers; //an array of numbers of length totalNums

        public Prob290C(int tot, int[] nums)
        {
            totalNums = tot;
            numbers = new int[totalNums];
            Array.Copy(nums, 0, numbers, 0, totalNums);
        }

        public double solve()
        {
            //HAI
            //I HAS A TUX
            //GIMMEH TUX

            //I HAS A FOO ITS 0
            //I HAS A BAR ITS 0
            //I HAS A BAZ ITS 0
            //I HAS A QUZ ITS 1
            int foo = 0, bar = 0, baz = 0, quz = 1;

            //TUX IS NOW A NUMBR

            //IM IN YR LOOP NERFIN YR TUX TIL BOTH SAEM TUX AN 0
            for (int i = 0; i < totalNums; ++i)
            {
                //I HAS A PUR
                //GIMMEH PUR
                //PUR IS NOW A NUMBR

                //FOO R SUM OF FOO AN PUR
                foo += numbers[i];
                //BAR R SUM OF BAR AN 1
                ++bar;

                //BOTH SAEM BIGGR OF PRODUKT OF FOO AN QUZ AN PRODUKT OF BAR BAZ AN PRODUKT OF FOO AN QUZ
                if (foo * quz * bar > baz * foo * quz)
                {
                    //O RLY?
                    //YA RLY

                    //BAZ R FOO
                    baz = foo;
                    //QUZ R BAR
                    quz = bar;
                }
                //OIC
                //IM OUTTA YR LOOP
            }
            //BAZ IS NOW A NUMBAR
            //VISIBLE SMOOSH QUOSHUNT OF BAZ QUZ
            //KTHXBYE
            return (double)baz / quz;
        }

        public override String ToString()
        {
            return "";
        }

        static void Main(string[] args)
        {
            int totalNums = Convert.ToInt32(Console.ReadLine());
            int[] numbers = new int[totalNums];
            for (int i = 0; i < totalNums; ++i)
            {
                numbers[i] = Convert.ToInt32(Console.ReadLine());
            }
            Prob290C prob = new Prob290C(totalNums, numbers);
            Console.WriteLine(prob.solve());
        }
    }
}


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

public class Solver
{
    #region I/O
    protected static TextReader reader;
    protected static TextWriter writer;

    static void Main()
    {
        #if ONLINE_JUDGE
        reader = Console.In;
        writer = Console.Out;
        #else
        reader = new StreamReader("..\\..\\input.txt");
        writer = new StreamWriter("..\\..\\output.txt");
        #endif
        Solver solver = new Solver();

        try
        {
            object result = solver.Solve();
            if (result != null)
            {
                writer.WriteLine(result);
                Console.Error.WriteLine(result);
            }
        }
        catch (Exception ex)
        {
            Console.Error.WriteLine(ex);
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read helpers

    static Queue<string> currentLineTokens = new Queue<string>();

    public static string ReadToken()
    {
        if (currentLineTokens.Count == 0)
        {
            currentLineTokens = new Queue<string>(reader.ReadLine().Trim().Split(' '));
        }
        return currentLineTokens.Dequeue();
    }

    public static string[] ReadTokens(bool fromCurrentLine = false)
    {
        string[] split;
        if (fromCurrentLine)
        {
            if (currentLineTokens.Count == 0)
                return new string[0];
            split = currentLineTokens.ToArray();
            currentLineTokens.Clear();
        }
        else
        {
            split = reader.ReadLine().Trim().Split(' ');
        }
        return split;
    }

    public static int ReadInt()
    {
        return int.Parse(ReadToken());
    }

    public static long ReadLong()
    {
        return long.Parse(ReadToken());
    }

    public static double ReadDouble()
    {
        return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
    }

    public static int[] ReadIntArray(bool fromCurrentLine = false)
    {
        string[] tokens = ReadTokens(fromCurrentLine);
        return tokens.Select(int.Parse).ToArray();
    }

    public static long[] ReadLongArray(bool fromCurrentLine = false)
    {
        string[] tokens = ReadTokens(fromCurrentLine);
        return tokens.Select(long.Parse).ToArray();
    }

    public static double[] ReadDoubleArray(bool fromCurrentLine = false)
    {
        string[] tokens = ReadTokens(fromCurrentLine);
        return tokens.Select(double.Parse).ToArray();
    }

    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
        {
            lines[i] = reader.ReadLine().Trim();
        }
        return lines;
    }

    #endregion

    public object Solve()
    {
        bool IT;
        int TUX = ReadInt();
        int FOO=0;
        int BAR=0;
        int BAZ=0;
        int QUZ=1;
        for (; TUX != 0; TUX--)
        {
            int PUR = ReadInt();
            FOO = (FOO + PUR);
            BAR = (BAR + 1);
            IT = (Math.Max(FOO * QUZ, BAR * BAZ)) == (FOO * QUZ);
            if(IT)
            {
                BAZ=FOO;
                QUZ=BAR;
            }
        }
        return 1.0 * BAZ / QUZ;

    }
}


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

namespace AprilFools2013C
{
    class Program
    {
        static void Main(string[] args)
        {
            int Tux;
            Tux = int.Parse(Console.ReadLine());

            var Foo = 0;
            var Bar = 0;
            var Baz = 0;
            var Quz = 1;

            for (; Tux > 0; Tux--)
            {
                int Pur;
                Pur = int.Parse(Console.ReadLine());

                Foo = Foo + Pur;
                Bar = Bar + 1;

                if (Math.Max(Foo * Quz, Bar * Baz) == Foo * Quz)
                {
                    Baz = Foo;
                    Quz = Bar;
                }
            }

            Console.WriteLine((double)Baz / (double)Quz);
        }
    }
}


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

    class Solution
    {
        //x, y幸運
        //n 持っている正の整数
        //数字10^9がxとyだけで構成されているか
        //
        int n;
        long res;
        List<string> a = new List<string>();

        public void solve(string[] ind)
        {

            n = int.Parse(ind[0]);
            res = 0;

            for (int i = 1; i <= 9; i++)
            {
                if (i <= n) res++;
                search(i.ToString(), 1);
            }

            Console.WriteLine(res);
        }

        void search(string str, int count)
        {
            if (int.Parse(str) > n) return;
            int cnt = count;
            string stri;
            for (int i = 0; i <= 9; i++)
            {
                stri = i.ToString();

                if (int.Parse(str + stri) > n) continue;

                if (str.IndexOf(stri) == -1)
                {
                    if (cnt == 2) continue;
                    //else cnt++;
                }

                res++;
                if (int.Parse(str + stri + "0") <= n)
                {
                    if (str.IndexOf(stri) == -1)  search(str + stri, cnt+1);
                    else search(str + stri, cnt);
                }
            }
        }
    }

    class Program
    {
        const int INPUT_TYPE = 1;
        static int in_line = 1;
        static void Main(string[] args)
        {
            Solution s = new Solution();
            ArrayList indata = new ArrayList();

#if !DEBUG

            switch (INPUT_TYPE)
            {
                case 2: //１行目に入力する行数を選択する
                    in_line = int.Parse(Console.ReadLine());
                    indata.Add(in_line.ToString());
                    goto case 1;
                case 1: //入力する行数固定
                    for (int i = 0; i < in_line; i++)
                        indata.Add(Console.ReadLine());

                    s.solve((string[])indata.ToArray(typeof(string)));
                    break;
            }
#else
            string[] debug_files = {
                                       "test1.txt",
                                       //"test2.txt",
                                       //"test3.txt"
                                   };

            foreach (var fname in debug_files)
            {
                try
                {
                    s.solve(File.ReadAllLines(fname));
                }
                catch (FileNotFoundException)
                {
                    //スルー
                }

            }
#endif
        }
    }


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

    class Solution
    {
        //x, y幸運
        //n 持っている正の整数
        //数字10^9がxとyだけで構成されているか
        //
        int n;
        long res;
        List<string> a = new List<string>();

        public void solve(string[] ind)
        {

            n = int.Parse(ind[0]);
            res = 0;

            for (int i = 1; i <= 9; i++)
            {
                if (i <= n) res++;
                search(i.ToString(), 1);
            }

            Console.WriteLine(res);
        }

        void search(string str, int count)
        {
            if (int.Parse(str) > n) return;
            int cnt = count;
            string stri;
            for (int i = 0; i <= 9; i++)
            {
                stri = i.ToString();

                if (int.Parse(str + stri) > n) continue;

                if (str.IndexOf(stri) == -1)
                {
                    if (cnt == 2) continue;
                    //else cnt++;
                }

                res++;
                if (int.Parse(str + stri + "0") <= n)
                {
                    if (str.IndexOf(stri) == -1)  search(str + stri, cnt+1);
                    else search(str + stri, cnt);
                }
            }
        }
    }

    class Program
    {
        const int INPUT_TYPE = 1;
        static int in_line = 1;
        static void Main(string[] args)
        {
            Solution s = new Solution();
            ArrayList indata = new ArrayList();

            switch (INPUT_TYPE)
            {
                case 2: //１行目に入力する行数を選択する
                    in_line = int.Parse(Console.ReadLine());
                    indata.Add(in_line.ToString());
                    goto case 1;
                case 1: //入力する行数固定
                    for (int i = 0; i < in_line; i++)
                        indata.Add(Console.ReadLine());

                    s.solve((string[])indata.ToArray(typeof(string)));
                    break;
            }

        }
    }


using System;
using System.IO;
using System.Text;

namespace Undoubtedly_Lucky_Numbers
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            string s = reader.ReadLine();
            int n = int.Parse(s);

            int count;
            if (n <= 100)
                count = n;
            else
            {
                count = 99;
                int d = 4;
                for (int le = 3; le < s.Length; le++)
                {
                    count += 9;
                    count += 9*(d-1);
                    count += 36*(2*d - 2);
                }

                int sl = s.Length;
                for (int i = 1; i < 10; i++)
                {
                    int k = i;
                    for (int j = 1; j < sl; j++)
                    {
                        k = k*10 + i;
                    }
                    if (k <= n)
                        count++;
                    for (int j = 0; j < 10; j++)
                    {
                        if (j == i)
                            continue;

                        for (int m = (1 << (sl-1)) - 2; m >= 0; m--)
                        {
                            int mask = m;
                            k = i;
                            for (int jj = 1; jj < sl; jj++)
                            {
                                k *= 10;
                                if ((mask & 1) == 1)
                                    k += i;
                                else k += j;
                                mask >>= 1;
                            }
                            if (k <= n)
                                count++;
                        }
                    }
                }
            }

            writer.WriteLine(count);
            writer.Flush();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;

namespace SP.Solutions.CodeForces.c338_196_1
{
	public class ProgramC
	{
	    private static long bestRes = long.MaxValue;

		public static void Main()
		{
			checked
			{
			    bestRes = long.MaxValue;
			    int n = int.Parse(Console.ReadLine());
			    var arr = Console.ReadLine().Split(' ').Select(long.Parse).Distinct().ToArray();
                Array.Sort(arr);

			    var primes = GetPrimes();

			    var nodes = new List<Node>();
                for (int i = 0; i < arr.Length; i++)
                {
                    nodes.Add(new Node(arr[i], getFactors(arr[i], primes), arr[i], false, 0));
                }

			    TryBuildTrees(nodes);
                Console.WriteLine(bestRes);
			}
		}

	    private static void TryBuildTrees(List<Node> nodes)
	    {
	        for (int i = 0 ; i  <nodes.Count ; i++)
	        for (int j = 0 ; j  <nodes.Count ; j++) if (j != i && !nodes[j].HasParent && nodes[i].Rem%nodes[j].N == 0)
	        {
	            var newNodes = new List<Node>();
                for (int k = 0; k < nodes.Count; k++) if (k != i && k != j) newNodes.Add(nodes[k]);
	            int add = nodes[j].Factors > 1 ? 1 : 0;
	            newNodes.Add(new Node(nodes[i].N, nodes[i].Factors, nodes[i].Rem/nodes[j].N, false, nodes[i].addFactors + nodes[j].addFactors + add));
                newNodes.Add(new Node(nodes[j].N, nodes[j].Factors, nodes[j].Rem, true, nodes[j].addFactors));
                TryBuildTrees(newNodes);
	        }

	        CalcPrice(nodes);
	    }

	    private static void CalcPrice(List<Node> nodes)
	    {
	        int n = 0;
	        long res = 0;
            foreach (var node in nodes) if (!node.HasParent)
            {
                if (node.Factors > 1) res++;
                res += node.Factors + node.addFactors;
                n++;
            }
	        if (n > 1) res++;
	        bestRes = Math.Min(bestRes, res);
	    }

	    static int getFactors(long n, long[] primes)
        {
            int res = 0;
            int i = 0;
            while (n > 1 && i < primes.Length)
            {
                if (n%primes[i] == 0)
                {
                    res++;
                    n /= primes[i];
                }
                else i++;
            }
	        if (i == primes.Length) res++;
            return res;
        }

        class Node
        {
            public override string ToString()
            {
                return string.Format("HasParent: {0}, N: {1}, Factors: {2}, Rem: {3}", HasParent, N, Factors, Rem);
            }

            public bool HasParent;
            public readonly long N;
            public readonly int Factors;
            public readonly long Rem;
            public readonly int addFactors;

            public Node(long n, int factors, long rem, bool hasParent, int addFactors)
            {
                HasParent = hasParent;
                this.addFactors = addFactors;
                N = n;
                Factors = factors;
                Rem = rem;
            }
        }

	    private static long[] GetPrimes()
	    {
	        const int max = 1000000;
	        var primes = new List<long>(80000);
	        primes.Add(2);
	        var isNotPrime = new bool[max + 1];
            for (int i = 3 ; i<= max ; i+=2) if (!isNotPrime[i])
            {
                primes.Add(i);
                for (int j = i*i; j <= max && j > 0; j += i) isNotPrime[j] = true;
            }
	        return primes.ToArray();
	    }
	}
}


using System;

namespace ProblemC
{
    class ProgramD
    {
        static void Main(string[] args)
        {
            string[] ar = Console.ReadLine().Split();

            int r = int.Parse(ar[0]);
            int b = int.Parse(ar[1]);

            int second = Math.Min(r, b);
            int first = (r + b - 1) - second;

            Console.WriteLine(first + " " + second);
        }
    }
}