module _38a;

import std.algorithm, std.conv, std.stdio, std.array;

int main()
{
	auto n = 0;
	readf!"%d"(n);
	readln();
	auto d = new int[n-1];
	for (auto i = 0; i < (n-1); i++) {
		scanf("%d", &d[i]);
	}
	readln();

	auto from_lv =0 , to_lv=0;
	readf!"%d %d"(from_lv, to_lv);
	readln();

	auto spent_years = 0;
	for (auto i = from_lv; i < to_lv; i++) {
		spent_years += d[i-1];
	}

	writefln("%d", spent_years);
    return 0;
}

import std.c.stdio;

void main() {
  int n; scanf("%d", &n);
  int[] d = new int[n];
  int a, b;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d", &d[i]);
  }
  scanf("%d %d", &a, &b);
  int x = 0;
  for (int i = a; i < b; i++) {
    x += d[i - 1];
  }
  printf("%d\n", x);
}

import std.stdio;

void assert_solve(int r,int[] ds, int a, int b){
  int sol = solve(ds,a,b);
  if (sol != r){
    writefln("Test %s-(%s,%s): Expected %s, got %s",ds,a,b,r,sol);
    assert(false);
  }
}

unittest{
  assert_solve(5,[0,5,6],1,2);
  assert_solve(11,[0,5,6],1,3);
}

int solve(int[] ds,int a,int b){
  ds[0] = 0;
  for(int i = 1; i < ds.length; i++){
    ds[i] += ds[i-1];
  }
  return ds[b-1] - ds[a-1];
}

void main(){
  int n;
  readf("%s\n",&n);

  int[] ds = new int[n];
  for(int i = 1; i < n; i++){
    readf("%s ",ds.ptr+i);
  }

  int a,b;
  readf("%s %s\n",&a,&b);

  writeln(solve(ds,a,b));
}


import std.algorithm;
import std.stdio;

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		auto a = new int [n];
		foreach (i; 0..n)
		{
			readf (" %s", &a[i]);
		}
		auto s = reduce !("a + b") (0, a);
		int res;
		if (s % 2 == 0)
		{
			s >>= 1;
			int t;
			foreach (i; 0..n - 1)
			{
				t += a[i];
				if (t == s)
				{
					res++;
				}
			}
		}
		writeln (res);
	}
}

import core.bitop;
import std.array;
import std.exception;
import std.format;

/**
 *  On the Web: $(WEB en.wikipedia.org/wiki/Fenwick_tree).
 */
struct FenwickTree (T)
 if (is (typeof (T.init + T.init) : T))
{
	private T [] table;
	private int ptwo;

	@property int length ()
	{
		return table.length;
	}

	this (int size)
	{
		enforce (size > 0);
		table.length = size;
		ptwo = 1 << bsr (size);
	}

	/**
	 *  Add delta to data[index].
	 *
	 *  Complexity: $(BIGOH log(n))
	 */
	void add (T2 = T) (int index, T2 delta = 1)
	{
		for ( ; index < length; index |= (index + 1))
		{
			table[index] += delta;
		}
	}

	/**
	 *  Find the sum of data[0..limit].
	 *
	 *  Complexity: $(BIGOH log(n))
	 */
	T2 sum (T2 = T) (int limit)
	{
		T2 res;
		for (limit--; limit >= 0; limit = (limit & (limit + 1)) - 1)
		{
			res += table[limit];
		}
		return res;
	}

	/**
	 *  Find the sum of data[left..right].
	 *
	 *  Complexity: $(BIGOH log(n))
	 */
	T2 sum (T2 = T) (int left, int right)
	{
		return sum !(T2) (right) - sum !(T2) (left);
	}

	/**
	 *  Find leftmost position such that sum of data[0..position] >= bound.
	 *
	 *  Returns length if no such position can be found.
	 *
	 *  Complexity: $(BIGOH log(n))
	 */
	int find (T2 = T) (T2 bound)
	{
		T2 csum;
		int position = 0;
		for (int cur = ptwo; cur > 0; cur >>= 1)
		{
			int npos = position + cur;
			if ((npos <= length) &&
			    csum + table[npos - 1] < bound)
			{
				position = npos;
				csum += table[npos - 1];
			}
		}
		return position;
       	}

	/**
	 *  Print the contents of table to a string.
	 *
	 *  Complexity: $(BIGOH (n))
	 */
	string toString ()
	{
		auto writer = appender !(string) ();
		foreach (i, c; table)
		{
			formattedWrite (writer, "sum[%s..%s] = %s\n",
			                (i + 1) & i, i + 1, c);
		}
		return writer.data;
	}
}

unittest
{
	immutable int MAX_N = 20;
	auto t = FenwickTree !(int) (MAX_N);
	foreach (i; 0..MAX_N)
	{
		t.add (i, i);
	}
	assert (t.sum (MAX_N) == 190);
	assert (t.sum !(long) (MAX_N) == 190);
	assert (t.find (int.min) == 0);
	assert (t.find (54) == 10);
	assert (t.find (55) == 10);
	assert (t.find (56) == 11);
	assert (t.find (long.max) == t.length);
	assert (t.sum (10) == 45);
	assert (t.sum (10, 20) == 190 - 45);
	foreach (i; 0..MAX_N)
	{
		assert (t.sum (i) == t.sum (0, i));
		assert (t.sum (0, i) + t.sum (i, MAX_N) == 190);
	}
	assert (t.toString () ==
	        "sum[0..1] = 0\n" ~
	        "sum[0..2] = 1\n" ~
	        "sum[2..3] = 2\n" ~
	        "sum[0..4] = 6\n" ~
	        "sum[4..5] = 4\n" ~
	        "sum[4..6] = 9\n" ~
	        "sum[6..7] = 6\n" ~
	        "sum[0..8] = 28\n" ~
	        "sum[8..9] = 8\n" ~
	        "sum[8..10] = 17\n" ~
	        "sum[10..11] = 10\n" ~
	        "sum[8..12] = 38\n" ~
	        "sum[12..13] = 12\n" ~
	        "sum[12..14] = 25\n" ~
	        "sum[14..15] = 14\n" ~
	        "sum[0..16] = 120\n" ~
	        "sum[16..17] = 16\n" ~
	        "sum[16..18] = 33\n" ~
	        "sum[18..19] = 18\n" ~
	        "sum[16..20] = 70\n"
	        );
}

import std.algorithm;
import std.stdio;

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		auto a = new int [n];
		foreach (i; 0..n)
		{
			readf (" %s", &a[i]);
		}
		auto t = FenwickTree !(int) (n);
		foreach (i; 0..n)
		{
			t.add (i, a[i]);
		}
		int res = 0;
		foreach (i; 1..n)
		{
			if (t.sum (0, i) == t.sum (i, n))
			{
				res++;
			}
		}
		writeln (res);
	}
}

import core.thread;
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex;

//	Input
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { tokens = readln.split; if (stdin.eof) throw new EOFException; } auto token = tokens[0]; tokens.popFront; return token; }
int readInt() { return to!int(readToken); }
long readLong() { return to!long(readToken); }
real readReal() { return to!real(readToken); }

//	chmin/chmax
void chmin(T)(ref T t, const T f) { if (t > f) t = f; }
void chmax(T)(ref T t, const T f) { if (t < f) t = f; }

//	Pair
struct Pair(S, T) {
	S x; T y;
	int opCmp(ref const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; }
	string toString() const { return "(" ~ to!string(x) ~ ", " ~ to!string(y) ~ ")"; }
}
auto pair(S, T)(S x, T y) { return Pair!(S, T)(x, y); }

//	Array
int binarySearch(T)(T[] as, bool delegate(T) test) { int low = -1, upp = as.length; for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(T[] as, T val) { return as.binarySearch((T a) { return (a <  val); }); }
int upperBound(T)(T[] as, T val) { return as.binarySearch((T a) { return (a <= val); }); }
T[] unique(T)(T[] as) { T[] bs; foreach (a; as) if (bs.empty || bs[$ - 1] != a) bs ~= a; return bs; }

int N;
long[] A;

void main(string[] args) {
	try {
	for (; ; ) {
		N = readInt;
		A = new long[N];
		foreach (i; 0 .. N) {
			A[i] = readLong;
		}

		const total = reduce!"a + b"(0L, A);
		long sum;
		int ans;
		foreach (i; 0 .. N - 1) {
			sum += A[i];
			if (sum == total - sum) {
				++ans;
			}
		}
		writeln(ans);
	}
	} catch (EOFException) {}
}

module _template;
import std.stdio;
import std.string;
import std.algorithm;
import std.container;
import std.range;
import std.math;
import std.numeric;
import std.conv;
import std.typecons;
import std.format;

struct IO {
        string[] tk;
        string read_string() {
                while (tk.empty)
                        tk = readln.split;
                auto tkt = tk.front;
                tk.popFront;
                return tkt;
        }
        int read_int() {
                return read_string.to!int;
        }
        double read_double() {
                return read_string.to!double;
        }
}

void main() {
        IO cin;
        int t = 1;
        // t = cin.read_int;
        while (t--) {
                int n = cin.read_int;
                int[] arr = new int[n];
                foreach (ref i; arr) i = cin.read_int;

                int[] sum_for = new int[n];
                sum_for[0] = arr[0];
                for (int i = 1; i < n; i++) {
                        sum_for[i] += arr[i] + sum_for[i - 1];
                }

                reverse(arr);

                int[] sum_back = new int[n];
                sum_back[0] = arr[0];
                for (int i = 1; i < n; i++) {
                        sum_back[i] += arr[i] + sum_back[i - 1];
                }

                int count = 0;
                for (int i = 0; i < n - 1; i++) {
                        if (sum_for[i] == sum_back[n - 2 - i])
                                count++;
                }

                writeln(count);
        }
}

import std.string, std.algorithm, std.conv, std.stdio, std.range;

void main()
{
    readln;
    auto ns = readln.split.map!(to!int);
    auto a = (0~ns.cumulativeFold!"a+b".array)[1..$-1];
    auto b = (ns.retro.cumulativeFold!"a+b".array.retro.array ~ 0)[1..$-1];
    writeln(a.zip(b).count!"a[0]==a[1]");
}

import std.string, std.algorithm, std.conv, std.stdio, std.range;

void main()
{
    readln;
    auto ns = readln.split.map!(to!int);
    auto a = chain(only(0), ns.cumulativeFold!"a+b").array.dropOne.dropBackOne;
    auto b = chain(only(0), ns.retro.cumulativeFold!"a+b").array.retro.dropOne.dropBackOne;
    writeln(a.zip(b).count!"a[0]==a[1]");
}

import core.bitop;
import std.array;
import std.exception;
import std.format;

/**
 *  On the Web: $(WEB en.wikipedia.org/wiki/Fenwick_tree).
 */
struct FenwickTree (T)
 if (is (typeof (T.init + T.init) : T))
{
	private T [] table;
	private int ptwo;

	@property int length ()
	{
		return table.length;
	}

	this (int size)
	{
		enforce (size > 0);
		table.length = size;
		ptwo = 1 << bsr (size);
	}

	/**
	 *  Add delta to data[index].
	 *
	 *  Complexity: $(BIGOH log(n))
	 */
	void add (T2 = T) (int index, T2 delta = 1)
	{
		for ( ; index < length; index |= (index + 1))
		{
			table[index] += delta;
		}
	}

	/**
	 *  Find the sum of data[0..limit].
	 *
	 *  Complexity: $(BIGOH log(n))
	 */
	T2 sum (T2 = T) (int limit)
	{
		T2 res;
		for (limit--; limit >= 0; limit = (limit & (limit + 1)) - 1)
		{
			res += table[limit];
		}
		return res;
	}

	/**
	 *  Find the sum of data[left..right].
	 *
	 *  Complexity: $(BIGOH log(n))
	 */
	T2 sum (T2 = T) (int left, int right)
	{
		return sum !(T2) (right) - sum !(T2) (left);
	}

	/**
	 *  Find leftmost position such that sum of data[0..position] >= bound.
	 *
	 *  Returns length if no such position can be found.
	 *
	 *  Complexity: $(BIGOH log(n))
	 */
	int find (T2 = T) (T2 bound)
	{
		T2 csum;
		int position = 0;
		for (int cur = ptwo; cur > 0; cur >>= 1)
		{
			int npos = position + cur;
			if ((npos <= length) &&
			    csum + table[npos - 1] < bound)
			{
				position = npos;
				csum += table[npos - 1];
			}
		}
		return position;
       	}

	/**
	 *  Print the contents of table to a string.
	 *
	 *  Complexity: $(BIGOH (n))
	 */
	string toString ()
	{
		auto writer = appender !(string) ();
		foreach (i, c; table)
		{
			formattedWrite (writer, "sum[%s..%s] = %s\n",
			                (i + 1) & i, i + 1, c);
		}
		return writer.data;
	}
}

unittest
{
	immutable int MAX_N = 20;
	auto t = FenwickTree !(int) (MAX_N);
	foreach (i; 0..MAX_N)
	{
		t.add (i, i);
	}
	assert (t.sum (MAX_N) == 190);
	assert (t.sum !(long) (MAX_N) == 190);
	assert (t.find (int.min) == 0);
	assert (t.find (54) == 10);
	assert (t.find (55) == 10);
	assert (t.find (56) == 11);
	assert (t.find (long.max) == t.length);
	assert (t.sum (10) == 45);
	assert (t.sum (10, 20) == 190 - 45);
	foreach (i; 0..MAX_N)
	{
		assert (t.sum (i) == t.sum (0, i));
		assert (t.sum (0, i) + t.sum (i, MAX_N) == 190);
	}
	assert (t.toString () ==
	        "sum[0..1] = 0\n" ~
	        "sum[0..2] = 1\n" ~
	        "sum[2..3] = 2\n" ~
	        "sum[0..4] = 6\n" ~
	        "sum[4..5] = 4\n" ~
	        "sum[4..6] = 9\n" ~
	        "sum[6..7] = 6\n" ~
	        "sum[0..8] = 28\n" ~
	        "sum[8..9] = 8\n" ~
	        "sum[8..10] = 17\n" ~
	        "sum[10..11] = 10\n" ~
	        "sum[8..12] = 38\n" ~
	        "sum[12..13] = 12\n" ~
	        "sum[12..14] = 25\n" ~
	        "sum[14..15] = 14\n" ~
	        "sum[0..16] = 120\n" ~
	        "sum[16..17] = 16\n" ~
	        "sum[16..18] = 33\n" ~
	        "sum[18..19] = 18\n" ~
	        "sum[16..20] = 70\n"
	        );
}

import std.algorithm;
import std.stdio;

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		auto a = new int [n];
		foreach (i; 0..n)
		{
			readf (" %s", &a[i]);
		}
		auto t = FenwickTree !(int) (n);
		foreach (i; 0..n)
		{
			t.add (i, a[i]);
		}
		int res = 0;
		foreach (i; 1..n - 1)
		{
			if (t.sum (0, i) == t.sum (i, n))
			{
				res++;
			}
		}
		writeln (res);
	}
}


import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.datetime.stopwatch;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    class folder {
        string name;
        string[] files;
        folder[] folders;

        this (string n) {
            name = n;
        }
    }

    folder root = new folder("root");

    string s;
    while ((s = readln.chomp) !is null) {
        auto els = s.split("\\");
        auto start = els[0] ~ els[1];
        auto file = els[$-1];
        els = start ~ els[2 .. $-1];

        auto now = root;
        foreach (e; els) {
            if (! now.folders.any!(f => f.name == e)) {
                now.folders ~= new folder(e);
            }

            now = now.folders.find!((f, e) => f.name == e)(e)[0];
        }

        now.files ~= file;
    }

    debug {
        void wf(folder f, int t) {
            (' ').repeat(t).to!string.write;
            writeln(f.name);
            foreach (fs; f.folders) {
                wf(fs, t+2);
            }
        }

        wf(root, 0);
    }

    Tuple!(int, int) getCnt(folder dir) {
        int dirs = dir.folders.length.to!int;
        int files = dir.files.length.to!int;

        auto ans = tuple(dirs, files);
        foreach (d; dir.folders) {
            auto res = getCnt(d);
            ans[0] += res[0];
            ans[1] += res[1];
        }

        return ans;
    }

    int mxd = 0, mxf = 0;
    foreach (dir; root.folders) {
        auto res = getCnt(dir);
        mxd = max(mxd, res[0]);
        mxf = max(mxf, res[1]);
    }

    writeln(mxd, ' ', mxf);
}

import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.datetime.stopwatch;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    class folder {
        string name;
        string[] files;
        folder[] folders;

        this (string n) {
            name = n;
        }
    }

    folder root = new folder("root");

    string s;
    while ((s = readln.chomp) !is null) {
        auto els = s.split("\\");
        auto start = els[0] ~ els[1];
        auto file = els[$-1];
        els = start ~ els[2 .. $-1];

        auto now = root;
        foreach (e; els) {
            if (! now.folders.any!(f => f.name == e)) {
                now.folders ~= new folder(e);
            }

            foreach (f; now.folders) {
                if (e == f.name) {
                    now = f;
                    break;
                }
            }
        }

        now.files ~= file;
    }

    debug {
        void wf(folder f, int t) {
            (' ').repeat(t).to!string.write;
            writeln(f.name);
            foreach (fs; f.folders) {
                wf(fs, t+2);
            }
        }

        wf(root, 0);
    }

    Tuple!(int, int) getCnt(folder dir) {
        int dirs = dir.folders.length.to!int;
        int files = dir.files.length.to!int;

        auto ans = tuple(dirs, files);
        foreach (d; dir.folders) {
            auto res = getCnt(d);
            ans[0] += res[0];
            ans[1] += res[1];
        }

        return ans;
    }

    int mxd = 0, mxf = 0;
    foreach (dir; root.folders) {
        auto res = getCnt(dir);
        mxd = max(mxd, res[0]);
        mxf = max(mxf, res[1]);
    }

    writeln(mxd, ' ', mxf);
}


import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.ascii, std.typecons;

void main()
{
    int t;
    readf("%s", &t);
    readln;

    while (t--) {
        int n;
        readf("%s", &n);
        readln;

        auto a = readln.chomp;
        auto b = readln.chomp;

        int[] ans;
        int p = 0;
        foreach (op; 0 .. n) {
            int cur = (a[p] - '0') ^ (op & 1);

            debug { writeln(p, ' ', op, ' ', cur); }

            if (cur == (b[n - op - 1] - '0')) {
                ans ~= 1;
            }

            ans ~= n - op;
            p = n - p - 1 + (op & 1);
        }

        ans.length.write;
        write(" ");
        ans.map!(to!string).join(" ").writeln;
    }
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	auto tests = readln.strip.to !(int);
	foreach (test; 0..tests)
	{
		auto n = readln.strip.to !(int);
		auto s = readln.strip.map !(q{a == '1'}).array;
		auto t = readln.strip.map !(q{a == '1'}).array;

		int [] answer;
		int lo = 0;
		int hi = n - 1;
		int p = 0;
		foreach_reverse (i; 0..n)
		{
			auto cur = (p ? !s[hi] : s[lo]);
			if (cur == t[i])
			{
				answer ~= 1;
			}
			answer ~= i + 1;
			if (p)
			{
				hi -= 1;
			}
			else
			{
				lo += 1;
			}
			p ^= 1;
		}
		writefln !("%s\n%(%s %)") (answer.length, answer);
	}
}

import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

void main() {
  try {
    for (; ; ) {
      const numCases = readInt();
      foreach (caseId; 0 .. numCases) {
        const N = readInt();
        const A = readToken();
        const B = readToken();

        int[] ansA, ansB;
        for (int i = 0, j; i < N; i = j) {
          for (j = i; j < N && A[i] == A[j]; ++j) {}
          if (!(j == N && A[N - 1] == '0')) {
            ansA ~= j;
          }
        }
        for (int i = 0, j; i < N; i = j) {
          for (j = i; j < N && B[i] == B[j]; ++j) {}
          if (!(j == N && B[N - 1] == '0')) {
            ansB ~= j;
          }
        }

        int[] ans;
        foreach (j; ansA) {
          ans ~= j;
        }
        foreach_reverse (j; ansB) {
          ans ~= j;
        }

        write(ans.length);
        foreach (j; ans) {
          write(" ", j);
        }
        writeln;
      }
    }
  } catch (EOFException e) {
  }
}

import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.typecons;
import std.variant;

size_t[] solve(string a, string b) {
	size_t[] result;
	foreach (i; 0 .. a.length) {
		if (a[i] != b[i]) {
			result.assumeSafeAppend ~= i + 1;
			result.assumeSafeAppend ~= 1;
			result.assumeSafeAppend ~= i + 1;
		}
	}
	return result;
}

void main() {
	long tt = readln().chomp.to!long;
	foreach (t; 0 .. tt) {
		readln();
		string a = readln().chomp;
		string b = readln().chomp;
		if (a == b) {
			writeln("0");
		}
		else {
			auto arr = solve(a, b);
			writeln(arr.length, " ", arr.map!(to!string).join(" "));
		}
	}
}

// 00A00B 00C00D
// b11a11 00C00D
// 0A00B1 00C00D

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto t = RD!int;
	auto ans = new int[][](t);
	foreach (ti; 0..t)
	{
		auto n = RD!int;
		auto a = RD!(char[]);
		auto b = RD!(char[]);

		foreach_reverse (i; 0..n)
		{
			if (a[i] == b[i]) continue;
			if (a[0] == b[i])
			{
				ans[ti] ~= 1;
				a[0] = a[i];
			}
			ans[ti] ~= i+1;
			int l, r = i;
			while (l <= r)
			{
				swap(a[l], a[r]);
				a[l] = cast(char)(((a[l]-'0')^1) + '0');
				if (l != r)
					a[r] = cast(char)(((a[r]-'0')^1) + '0');
				++l; --r;
			}
			continue;
		}
	}

	foreach (e; ans)
	{
		write(e.length);
		if (e.empty)
		{
			writeln;
			continue;
		}
		write(" ");
		e.map!(to!string).join(" ").writeln;
	}
	stdout.flush;
	debug readln;
}


//ahmat
import core.stdc.stdio:scanf,printf,puts;
import core.bitop;
import std.stdio;
import std.string;
import std.algorithm;
import std.functional;
import std.array;
import std.container;
import std.conv;
import std.container;
import std.typecons;
import std.math;
import std.numeric;
pragma(inline,true);

bool isv(ref char c){
    return c=='a'||c=='e'||c=='i'||c=='o'||c=='u';
}
void main(){
    char[] s=readln.strip.to!(char[]),
           t=readln.strip.to!(char[]);
    if(s.length!=t.length)
        writeln("No");
    else{
        foreach(i;0..s.length){
            if((!s[i].isv || !t[i].isv) && (s[i].isv || t[i].isv)){
                writeln("No");
                return;
            }
        }
        writeln("Yes");
    }
}

import std.algorithm;
import std.container;
import std.conv;
import std.format;
import std.range;
import std.stdio;
import std.string;

bool isVowel(C)(C c) {
    return "aeiou".canFind(c);
}

void main() {
    string s = readln.strip;
    string t = readln.strip;

    bool[] cv_s = s.map!(c => c.isVowel).array;
    bool[] cv_t = t.map!(c => c.isVowel).array;

    if (cv_s == cv_t) {
        writeln("Yes");
    } else {
        writeln("No");
    }
}


import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

enum INF = 10^^9;

void main() {
  try {
    for (; ; ) {
      const N = readInt();
      auto A = new int[N];
      foreach (i; 0 .. N) {
        A[i] = readInt();
      }

      const K = (N + 1) / 2;
      auto dp = new int[][](K + 1, N);
      foreach (k; 0 .. K + 1) {
        dp[k][] = INF;
      }
      foreach (i; 0 .. N) {
        int cost;
        if (i - 1 >= 0) {
          cost += max(A[i - 1] - A[i] + 1, 0);
        }
        if (i + 1 < N) {
          cost += max(A[i + 1] - A[i] + 1, 0);
        }
        dp[1][i] = cost;
      }
      auto dpMin = new int[N + 1];
      foreach (k; 1 .. K) {
        dpMin[0] = INF;
        foreach (i; 0 .. N) {
          dpMin[i + 1] = min(dpMin[i], dp[k][i]);
        }
        foreach (i; 2 .. N) {
          {
            int cost = dpMin[i - 2];
            cost += max(A[i - 1] - A[i] + 1, 0);
            if (i + 1 < N) {
              cost += max(A[i + 1] - A[i] + 1, 0);
            }
            chmin(dp[k + 1][i], cost);
          }
          {
            int cost = dp[k][i - 2];
            cost -= max(A[i - 1] - A[i - 2] + 1, 0);
            cost += max(A[i - 1] - min(A[i - 2], A[i]) + 1, 0);
            if (i + 1 < N) {
              cost += max(A[i + 1] - A[i] + 1, 0);
            }
            chmin(dp[k + 1][i], cost);
          }
        }
      }
      debug {
        foreach (k; 1 .. K + 1) {
          writeln(k, ": ", dp[k]);
        }
      }

      foreach (k; 1 .. K + 1) {
        if (k > 1) write(" ");
        write(dp[k].minElement);
      }
      writeln();
    }
  } catch (EOFException e) {
  }
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;

immutable int infinity = int.max / 2;

int cost (int prev, int cur, int next)
{
	int res = 0;
	res += max (0, prev + 1 - cur);
	res += max (0, next + 1 - cur);
	return res;
}

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		readln;
		auto a = readln.splitter.map !(to !(int)).array;
		int m = (n + 1) / 2;

		auto f = new int [] [] (2, n);
		int b = 0;
		int [] ans;
		foreach (i; 0..n)
		{
			int prev = (i - 1 >= 0) ? a[i - 1] : -1;
			int next = (i + 1 < n) ? a[i + 1] : -1;
			f[b][i] = cost (prev, a[i], next);
		}
		ans ~= minElement (f[b]);
		debug {writeln (f[b]);}

		foreach (k; 1..m)
		{
			b ^= 1;
			debug {f[b][] = -1;}
			int minHistory = infinity;
			int best = infinity;
			foreach (i; k * 2..n)
			{
				int prev = a[i - 1];
				int prevClose = min (prev, a[i - 2] - 1);
				int next = (i + 1 < n) ? a[i + 1] : -1;
				int cur = cost (prevClose, a[i], next) +
				    f[!b][i - 2];
				cur = min (cur, cost (prev, a[i], next) +
				    minHistory);

				f[b][i] = cur;
				best = min (best, cur);
				minHistory = min (minHistory, f[!b][i - 2]);
			}
			ans ~= best;
			debug {writeln (f[b]);}
		}

		writefln ("%(%s %)", ans);
	}
}


// Cheese-Cracker: cheese-cracker.github.io

void theCode(){
    int n = scan!int;
    auto w = scan!(dchar[]);
    int l1, l2, r1, r2;
    for(int i = n/2; i < n; ++i){
        if(w[i] == '0'){
            l1 = 0;
            r1 = i;
            l2 = 0;
            r2 = i-1;
            writeln(l1+1, " ", r1+1, " ", l2+1, " ", r2+1);
            return;
        }
    }
    for(int i = 0; i < n/2; ++i){
        if(w[i] == '0'){
            l1 = i;
            r1 = n-1;
            l2 = i+1;
            r2 = n-1;
            writeln(l1+1, " ", r1+1, " ", l2+1, " ", r2+1);
            return;
        }
    }
    for(int i = 0; i < n; ++i){
        assert(w[i] == '1');
    }
    l1 = 0;
    r1 = n/2;
    l2 = 1;
    r2 = min(n/2 + 1, n-1);
    writeln(l1+1, " ", r1+1, " ", l2+1, " ", r2+1);
}

void main(){
    long tests = scan;        // Toggle!
    while(tests--) theCode();
}

/*********  That's All Folks!  *********/
import std.stdio, std.random, std.functional, std.container, std.algorithm;
import std.numeric, std.range, std.typecons, std.string, std.math, std.conv;
string[] tk; T scan(T=long)(){while(!tk.length)tk = readln.split; string a=tk.front; tk.popFront; return a.to!T;}
T[] scanArray(T=long)(){ auto r = readln.split.to!(T[]); return r; }
void show(A...)(A a){ debug{ foreach(t; a){stderr.write(t, "| ");} stderr.writeln; } }
alias ll = long, tup = Tuple!(long, "x",  long, "y");

import std.algorithm, std.array, std.container, std.conv, std.format, std.math, std.numeric, std.random, std.range, std.stdio, std.string, std.typecons, core.bitop;

void solve(string s)
{
  int lastzero = -1;
  foreach_reverse (i ; 0 .. cast(int)s.length) {
    if (s[i] == '0') {
      lastzero = i;
      break;
    }
  }
  if (lastzero >= cast(int)s.length / 2) {
//    writeln(s[1 - 1 .. lastzero]);
//    writeln(s[1 - 1 .. lastzero + 1]);
    writefln("%d %d %d %d", 1, lastzero + 1, 1, lastzero);
    return;
  }
  int mididx = cast(int)s.length / 2;
  if (s[mididx - 1] == '1') {
//    writeln(s[mididx + 1 - 1 .. s.length]);
//    writeln(s[mididx - 1 .. s.length - 1]);
    writefln("%d %d %d %d", mididx + 1, s.length, mididx, s.length - 1);
  } else {
//    writeln(s[mididx - 1 .. s.length]);
//    writeln(s[mididx + 1 - 1 .. s.length]);
    writefln("%d %d %d %d", mididx, s.length, mididx + 1, s.length);
  }
}

void main()
{
  long t;
  readf!" %d "(t);
  while (t--) {
    long n;
    readln.formattedRead!" %d "(n);
    string s = readln.strip;
//    writeln(s);
    solve(s);
  }
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }
double[] rotate(double[] vec, double rad) { return [cos(rad)*vec[0] - sin(rad)*vec[1], sin(rad)*vec[0] + cos(rad)*vec[1]]; }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(ref long x, long y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto t = RD!int;
	auto ans = new long[][](t);
	foreach (ti; 0..t)
	{
		auto n = RD!int;
		auto s = RD!string;

		long pos;
		foreach (i; n/2..n)
		{
			if (s[i] == '0')
			{
				pos = i;
				break;
			}
		}
		if (pos != 0)
		{
			ans[ti] = [1, pos+1, 1, pos];
			continue;
		}

		if (s[n/2-1] == '1')
			ans[ti] = [n/2, n-1, n/2+1, n];
		else
			ans[ti] = [n/2+1, n, n/2, n];
	}

	foreach (e; ans)
	{
		writeln(e[0], " ", e[1], " ", e[2], " ", e[3]);
	}
	stdout.flush;
	debug readln;
}

// Cheese-Cracker: cheese-cracker.github.io

void theCode(){
    int n = scan!int;
    auto w = scan!(dchar[]);
    int l1, l2, r1, r2;
    for(int i = n/2; i < n; ++i){
        if(w[i] == '0'){
            l1 = 0;
            r1 = i;
            l2 = 0;
            r2 = i-1;
            writeln(l1+1, " ", r1+1, " ", l2+1, " ", r2+1);
            return;
        }
    }
    for(int i = 0; i < n/2; ++i){
        if(w[i] == '0'){
            l1 = i;
            r1 = n-1;
            l2 = i+1;
            r2 = n-1;
            writeln(l1+1, " ", r1+1, " ", l2+1, " ", r2+1);
            return;
        }
    }
    for(int i = 0; i < n; ++i){
        assert(w[i] == '1');
    }
    l1 = 0;
    r1 = n/2;
    l2 = 1;
    r2 = n/2 + 1;
    writeln(l1+1, " ", r1+1, " ", l2+1, " ", r2+1);
}

void main(){
    long tests = scan;        // Toggle!
    while(tests--) theCode();
}

/*********  That's All Folks!  *********/
import std.stdio, std.random, std.functional, std.container, std.algorithm;
import std.numeric, std.range, std.typecons, std.string, std.math, std.conv;
string[] tk; T scan(T=long)(){while(!tk.length)tk = readln.split; string a=tk.front; tk.popFront; return a.to!T;}
T[] scanArray(T=long)(){ auto r = readln.split.to!(T[]); return r; }
void show(A...)(A a){ debug{ foreach(t; a){stderr.write(t, "| ");} stderr.writeln; } }
alias ll = long, tup = Tuple!(long, "x",  long, "y");

// Cheese-Cracker: cheese-cracker.github.io

void theCode(){
    int n = scan!int;
    auto w = scan!(dchar[]);
    int l1, l2, r1, r2;
    for(int i = 0; i < n/2; ++i){
        if(w[i] == '0'){
            l1 = i;
            r1 = n-1;
            l2 = i+1;
            r2 = n-1;
            writeln(l1+1, " ", r1+1, " ", l2+1, " ", r2+1);
            return;
        }
    }
    for(int i = n/2; i < n; ++i){
        if(w[i] == '0'){
            l1 = 0;
            r1 = i;
            l2 = 0;
            r2 = i-1;
            writeln(l1+1, " ", r1+1, " ", l2+1, " ", r2+1);
            return;
        }
    }
    for(int i = 0; i < n; ++i){
        assert(w[i] == '1');
    }
    l1 = 0;
    r1 = n/2;
    l2 = 1;
    r2 = n/2 + 1;
    writeln(l1+1, " ", r1+1, " ", l2+1, " ", r2+1);
}

void main(){
    long tests = scan;        // Toggle!
    while(tests--) theCode();
}

/*********  That's All Folks!  *********/
import std.stdio, std.random, std.functional, std.container, std.algorithm;
import std.numeric, std.range, std.typecons, std.string, std.math, std.conv;
string[] tk; T scan(T=long)(){while(!tk.length)tk = readln.split; string a=tk.front; tk.popFront; return a.to!T;}
T[] scanArray(T=long)(){ auto r = readln.split.to!(T[]); return r; }
void show(A...)(A a){ debug{ foreach(t; a){stderr.write(t, "| ");} stderr.writeln; } }
alias ll = long, tup = Tuple!(long, "x",  long, "y");

// Cheese-Cracker: cheese-cracker.github.io

void theCode(){
    int n = scan!int;
    auto w = scan!(dchar[]);
    int l1, l2, r1, r2;
    dchar[] sol1, sol2;
    for(int i = 0; i < n/2; ++i){
        if(w[i] == '0'){
            /* sol1 ~= w[i]; */
            /* for(int j = i + 1; j < n; ++j){ */
            /*   sol1 ~= w[j]; */
            /*   sol2 ~= w[j]; */
            /*   f = 1; */
            /*   break; */
            /* } */
            l1 = i;
            r1 = n-1;
            l2 = i+1;
            r2 = n-1;
            writeln(l1+1, " ", r1+1, " ", l2+1, " ", r2+1);
            return;
        }
    }
    for(int i = n/2; i < n; ++i){
        if(w[i] == '0'){
            /* for(int j = n/2; j < i; ++j){ */
            /*     sol1 ~= w[i]; */
            /*     sol2 ~= w[i]; */
            /* } */
            /* f = 1; */
            /* sol1 ~= w[i]; */
            l1 = 0;
            r1 = i;
            l2 = 0;
            r2 = i-1;
            writeln(l1+1, " ", r1+1, " ", l2+1, " ", r2+1);
            return;
        }
    }
    l1 = 0;
    r1 = n/2;
    l2 = 1;
    r2 = n/2 + 1;
    writeln(l1+1, " ", r1+1, " ", l2+1, " ", r2+1);
}

void main(){
    long tests = scan;        // Toggle!
    while(tests--) theCode();
}

/*********  That's All Folks!  *********/
import std.stdio, std.random, std.functional, std.container, std.algorithm;
import std.numeric, std.range, std.typecons, std.string, std.math, std.conv;
string[] tk; T scan(T=long)(){while(!tk.length)tk = readln.split; string a=tk.front; tk.popFront; return a.to!T;}
T[] scanArray(T=long)(){ auto r = readln.split.to!(T[]); return r; }
void show(A...)(A a){ debug{ foreach(t; a){stderr.write(t, "| ");} stderr.writeln; } }
alias ll = long, tup = Tuple!(long, "x",  long, "y");

import std.algorithm, std.array, std.container, std.conv, std.format, std.math, std.numeric, std.random, std.range, std.stdio, std.string, std.typecons, core.bitop;

void solve(string s)
{
  int lastzero = -1;
  foreach_reverse (i ; 0 .. cast(int)s.length) {
    if (s[i] == '0') {
      lastzero = i;
      break;
    }
  }
  if (lastzero >= s.length / 2) {
//    writeln(s[1 - 1 .. lastzero]);
//    writeln(s[1 - 1 .. lastzero + 1]);
    writefln("%d %d %d %d", 1, lastzero + 1, 1, lastzero);
    return;
  }
  int mididx = cast(int)s.length / 2;
  if (s[mididx - 1] == '1') {
//    writeln(s[mididx + 1 - 1 .. s.length]);
//    writeln(s[mididx - 1 .. s.length - 1]);
    writefln("%d %d %d %d", mididx + 1, s.length, mididx, s.length - 1);
  } else {
//    writeln(s[mididx - 1 .. s.length]);
//    writeln(s[mididx + 1 - 1 .. s.length]);
    writefln("%d %d %d %d", mididx, s.length, mididx + 1, s.length);
  }
}

void main()
{
  long t;
  readf!" %d "(t);
  while (t--) {
    long n;
    readln.formattedRead!" %d "(n);
    string s = readln.strip;
//    writeln(s);
    solve(s);
  }
}

import std.algorithm, std.array, std.container, std.conv, std.format, std.math, std.numeric, std.random, std.range, std.stdio, std.string, std.typecons, core.bitop;

void solve(string s)
{
  int lastzero = -1;
  foreach_reverse (i ; 0 .. cast(int)s.length) {
    if (s[i] == '0') {
      lastzero = i;
      break;
    }
  }
  if (lastzero >= s.length / 2) {
//    writeln(s[1 - 1 .. lastzero]);
//    writeln(s[1 - 1 .. lastzero + 1]);
    writefln("%d %d %d %d", 1, lastzero, 1, lastzero + 1);
    return;
  }
  int mididx = cast(int)s.length / 2;
  if (s[mididx - 1] == '1') {
//    writeln(s[mididx + 1 - 1 .. s.length]);
//    writeln(s[mididx - 1 .. s.length - 1]);
    writefln("%d %d %d %d", mididx + 1, s.length, mididx, s.length - 1);
  } else {
//    writeln(s[mididx - 1 .. s.length]);
//    writeln(s[mididx + 1 - 1 .. s.length]);
    writefln("%d %d %d %d", mididx, s.length, mididx + 1, s.length);
  }
}

void main()
{
  long t;
  readf!" %d "(t);
  while (t--) {
    long n;
    readln.formattedRead!" %d "(n);
    string s = readln.strip;
//    writeln(s);
    solve(s);
  }
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }
double[] rotate(double[] vec, double rad) { return [cos(rad)*vec[0] - sin(rad)*vec[1], sin(rad)*vec[0] + cos(rad)*vec[1]]; }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(ref long x, long y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto t = RD!int;
	auto ans = new long[][](t);
	foreach (ti; 0..t)
	{
		auto n = RD!int;
		auto s = RD!string;

		long pos;
		foreach (i; n/2..n)
		{
			if (s[i] == '0')
			{
				pos = i;
				break;
			}
		}
		if (pos != 0)
		{
			ans[ti] = [1, pos, 1, pos+1];
			continue;
		}

		if (s[n/2-1] == '1')
			ans[ti] = [n/2, n-1, n/2+1, n];
		else
			ans[ti] = [n/2, n, n/2+1, n];
	}

	foreach (e; ans)
	{
		writeln(e[0], " ", e[1], " ", e[2], " ", e[3]);
	}
	stdout.flush;
	debug readln;
}


import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

void main() {
  try {
    for (; ; ) {
      const numCases = readInt();
      foreach (caseId; 0 .. numCases) {
        const N = readInt();
        const X = readInt();
        const Y = readInt();
        auto B = new int[N];
        foreach (i; 0 .. N) {
          B[i] = readInt();
        }

        const M = N + 2;
        auto iss = new int[][M];
        foreach (i; 0 .. N) {
          iss[B[i]] ~= i;
        }
        int fake;
        foreach (b; 1 .. M) {
          if (iss[b].empty) {
            fake = b;
            break;
          }
        }

        int mLim;
        foreach (m; 0 .. N - X + 1) {
          if (min(2 * (N - X - m), N - X) >= Y - X) {
            chmax(mLim, m);
          }
        }
        debug {
          writeln("mLim = ", mLim);
        }

        int must;
        foreach (b; 1 .. M) {
          const len = cast(int)(iss[b].length);
          must += max(len - mLim, 0);
        }
        if (must <= X) {
          int[] hits;
          foreach (b; 1 .. M) {
            const len = cast(int)(iss[b].length);
            if (len - mLim >= 0) {
              hits ~= iss[b][mLim .. len];
              iss[b].length = mLim;
            }
          }
          int x = X - must;
          foreach (b; 1 .. M) {
            const len = cast(int)(iss[b].length);
            const tmp = min(len, x);
            hits ~= iss[b][len - tmp .. len];
            iss[b].length = len - tmp;
            x -= tmp;
          }
          debug {
            writeln("hits = ", hits);
            writeln("iss = ", iss);
          }
          auto ans = new int[N];
          ans[] = fake;
          foreach (i; hits) {
            ans[i] = B[i];
          }
          int bm;
          foreach (b; 1 .. M) {
            if (iss[bm].length < iss[b].length) {
              bm = b;
            }
          }
          if (2 * iss[bm].length <= N - X) {
            int[] blows;
            foreach (b; 1 .. M) {
              blows ~= iss[b];
            }
            foreach (j; 0 .. Y - X) {
              ans[blows[j]] = B[blows[(j + (N - X) / 2) % (N - X)]];
            }
          } else {
            int[] others;
            foreach (b; 1 .. M) {
              if (b != bm) {
                others ~= iss[b];
              }
            }
            const othersLen = cast(int)(others.length);
            assert(2 * othersLen >= Y - X);
            int y = Y - X;
            foreach (j; 0 .. othersLen) {
              if (y > 0) {
                ans[others[j]] = B[iss[bm][j]];
                --y;
              }
            }
            foreach (j; 0 .. othersLen) {
              if (y > 0) {
                ans[iss[bm][j]] = B[others[j]];
                --y;
              }
            }
          }
          writeln("YES");
          foreach (i; 0 .. N) {
            if (i > 0) write(" ");
            write(ans[i]);
          }
          writeln;
        } else {
          writeln("NO");
        }
      }
    }
  } catch (EOFException e) {
  }
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	auto tests = readln.strip.to !(int);
multitest_loop:
	foreach (test; 0..tests)
	{
		int n, x, y;
		readf !(" %s %s %s") (n, x, y);
		readln;
		auto a = readln.splitter.map !(to !(int)).array;

		int [int] b;
		foreach (ref t; a)
		{
			b[t] += 1;
		}
		auto c = b.byPair.array;
		c.schwartzSort !(q{-a.value});
		y -= x;

		int [] inPlace;
		while (x > 0)
		{
			int cur = c.front.value;
			auto d = c;
			while (x > 0 && !d.empty && d.front.value == cur)
			{
				inPlace ~= d.front.key;
				d.front.value -= 1;
				d.popFront ();
				x -= 1;
			}
		}

		int notFound = 1;
		while (notFound in b)
		{
			notFound += 1;
		}

		c.schwartzSort !(q{-a.value});

		int [] left;
		foreach (ref p; c)
		{
			foreach (i; 0..p.value)
			{
				left ~= p.key;
			}
		}

		int [2] [] trans;
		int len = left.length.to !(int);
		int hi = len / 2;
		foreach (lo; 0..len)
		{
			int dest = left[hi];
			if (y == 0 || left[lo] == dest)
			{
				dest = notFound;
			}
			else
			{
				y -= 1;
			}
			trans ~= [left[lo], dest];
			hi = (hi + 1) % (len + !len);
		}

		if (y > 0)
		{
			writeln ("NO");
			continue multitest_loop;
		}

		sort (inPlace);
		sort (trans);
		auto q = n.iota.array;
		makeIndex (a, q);
		auto res = new int [n];
		foreach (i; q)
		{
			if (!inPlace.empty && inPlace.front == a[i])
			{
				res[i] = a[i];
				inPlace.popFront ();
			}
			else if (!trans.empty && trans.front[0] == a[i])
			{
				res[i] = trans.front[1];
				trans.popFront ();
			}
			else
			{
				assert (false);
			}
		}
		writeln ("YES");
		writefln !("%(%s %)") (res);
	}
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	auto tests = readln.strip.to !(int);
multitest_loop:
	foreach (test; 0..tests)
	{
		int n, x, y;
		readf !(" %s %s %s") (n, x, y);
		readln;
		auto a = readln.splitter.map !(to !(int)).array;

		int [int] b;
		foreach (ref t; a)
		{
			b[t] += 1;
		}
		auto c = b.byPair.array;
		c.schwartzSort !(q{-a.value});
		y -= x;

		int [] inPlace;
		while (x > 0)
		{
			int cur = c.front.value;
			auto d = c;
			while (x > 0 && !d.empty && d.front.value == cur)
			{
				inPlace ~= d.front.key;
				d.front.value -= 1;
				d.popFront ();
				x -= 1;
			}
		}

		int notFound = 1;
		while (notFound in b)
		{
			notFound += 1;
		}

		c.schwartzSort !(q{-a.value});

		int [] left;
		foreach (ref p; c)
		{
			foreach (i; 0..p.value)
			{
				left ~= p.key;
			}
		}

		int [2] [] trans;
		int len = left.length.to !(int);
		int hi = c.front.value % (len + !len);
		foreach (lo; 0..len)
		{
			int dest = (y > 0) ? left[hi] : notFound;
			y -= 1;
			trans ~= [left[lo], dest];
			hi = (hi + 1) % (len + !len);
		}

		if (trans.any !(p => p[0] == p[1]))
		{
			writeln ("NO");
			continue multitest_loop;
		}

		sort (inPlace);
		sort (trans);
		auto q = n.iota.array;
		makeIndex (a, q);
		auto res = new int [n];
		foreach (i; q)
		{
			if (!inPlace.empty && inPlace.front == a[i])
			{
				res[i] = a[i];
				inPlace.popFront ();
			}
			else if (!trans.empty && trans.front[0] == a[i])
			{
				res[i] = trans.front[1];
				trans.popFront ();
			}
			else
			{
				assert (false);
			}
		}
		writeln ("YES");
		writefln !("%(%s %)") (res);
	}
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	auto tests = readln.strip.to !(int);
multitest_loop:
	foreach (test; 0..tests)
	{
		int n, x, y;
		readf !(" %s %s %s") (n, x, y);
		readln;
		auto a = readln.splitter.map !(to !(int)).array;

		int [int] b;
		foreach (ref t; a)
		{
			b[t] += 1;
		}
		auto c = b.byPair.array;
		c.schwartzSort !(q{-a.value});
		y -= x;

		int [] inPlace;
		while (x > 0)
		{
			int cur = c.front.value;
			auto d = c;
			while (x > 0 && !d.empty && d.front.value == cur)
			{
				inPlace ~= d.front.key;
				d.front.value -= 1;
				d.popFront ();
				x -= 1;
			}
		}

		int notFound = 1;
		while (notFound in b)
		{
			notFound += 1;
		}

		c.schwartzSort !(q{-a.value});

		int [] left;
		foreach (ref p; c)
		{
			foreach (i; 0..p.value)
			{
				left ~= p.key;
			}
		}

		int [2] [] trans;
		int hi = c.front.value;
		int len = left.length.to !(int);
		foreach (lo; 0..len)
		{
			int dest = (y > 0) ? left[hi] : notFound;
			y -= 1;
			trans ~= [left[lo], dest];
			hi = (hi + 1) % len;
		}

		if (trans.any !(p => p[0] == p[1]))
		{
			writeln ("NO");
			continue multitest_loop;
		}

		sort (inPlace);
		sort (trans);
		auto q = n.iota.array;
		makeIndex (a, q);
		auto res = new int [n];
		foreach (i; q)
		{
			if (!inPlace.empty && inPlace.front == a[i])
			{
				res[i] = a[i];
				inPlace.popFront ();
			}
			else if (!trans.empty && trans.front[0] == a[i])
			{
				res[i] = trans.front[1];
				trans.popFront ();
			}
			else
			{
				assert (false);
			}
		}
		writeln ("YES");
		writefln !("%(%s %)") (res);
	}
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	auto tests = readln.strip.to !(int);
multitest_loop:
	foreach (test; 0..tests)
	{
		int n, x, y;
		readf !(" %s %s %s") (n, x, y);
		readln;
		auto a = readln.splitter.map !(to !(int)).array;

		int [int] b;
		foreach (ref t; a)
		{
			b[t] += 1;
		}
		auto c = b.byPair.array;
		c.schwartzSort !(q{-a.value});
		y -= x;

		int [] inPlace;
		while (x > 0)
		{
			int cur = c.front.value;
			auto d = c;
			while (x > 0 && !d.empty && d.front.value == cur)
			{
				inPlace ~= d.front.key;
				d.front.value -= 1;
				d.popFront ();
				x -= 1;
			}
		}

		int notFound = 1;
		while (notFound in b)
		{
			notFound += 1;
		}

		c.schwartzSort !(q{-a.value});

		int [] left;
		foreach (ref p; c)
		{
			foreach (i; 0..p.value)
			{
				left ~= p.key;
			}
		}

		int [2] [] trans;
		int len = left.length.to !(int);
		int hi = len / 2;
		foreach (lo; 0..len)
		{
			int dest = left[hi];
			if (y == 0 || left[lo] == dest)
			{
				dest = notFound;
			}
			else
			{
				y -= 1;
			}
			trans ~= [left[lo], dest];
			hi = (hi + 1) % (len + !len);
		}

		if (trans.any !(p => p[0] == p[1]))
		{
			writeln ("NO");
			continue multitest_loop;
		}

		sort (inPlace);
		sort (trans);
		auto q = n.iota.array;
		makeIndex (a, q);
		auto res = new int [n];
		foreach (i; q)
		{
			if (!inPlace.empty && inPlace.front == a[i])
			{
				res[i] = a[i];
				inPlace.popFront ();
			}
			else if (!trans.empty && trans.front[0] == a[i])
			{
				res[i] = trans.front[1];
				trans.popFront ();
			}
			else
			{
				assert (false);
			}
		}
		writeln ("YES");
		writefln !("%(%s %)") (res);
	}
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	auto tests = readln.strip.to !(int);
multitest_loop:
	foreach (test; 0..tests)
	{
		int n, x, y;
		readf !(" %s %s %s") (n, x, y);
		readln;
		auto a = readln.splitter.map !(to !(int)).array;

		int [int] b;
		foreach (ref t; a)
		{
			b[t] += 1;
		}
		auto c = b.byPair.array;
		c.schwartzSort !(q{-a.value});
		y -= x;

		int [] inPlace;
		while (x > 0)
		{
			int cur = c.front.value;
			auto d = c;
			while (x > 0 && !d.empty && d.front.value == cur)
			{
				inPlace ~= d.front.key;
				d.front.value -= 1;
				d.popFront ();
				x -= 1;
			}
		}

		int notFound = 1;
		while (notFound in b)
		{
			notFound += 1;
		}

		c.schwartzSort !(q{-a.value});

		int [] left;
		foreach (ref p; c)
		{
			foreach (i; 0..p.value)
			{
				left ~= p.key;
			}
		}

		int [2] [] trans;
		int len = left.length.to !(int);
		int hi = len / 2;
		foreach (lo; 0..len)
		{
			int dest = (y > 0) ? left[lo] : notFound;
			y -= 1;
			trans ~= [left[hi], dest];
			hi = (hi + 1) % (len + !len);
		}

		if (trans.any !(p => p[0] == p[1]))
		{
			writeln ("NO");
			continue multitest_loop;
		}

		sort (inPlace);
		sort (trans);
		auto q = n.iota.array;
		makeIndex (a, q);
		auto res = new int [n];
		foreach (i; q)
		{
			if (!inPlace.empty && inPlace.front == a[i])
			{
				res[i] = a[i];
				inPlace.popFront ();
			}
			else if (!trans.empty && trans.front[0] == a[i])
			{
				res[i] = trans.front[1];
				trans.popFront ();
			}
			else
			{
				assert (false);
			}
		}
		writeln ("YES");
		writefln !("%(%s %)") (res);
	}
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	auto tests = readln.strip.to !(int);
multitest_loop:
	foreach (test; 0..tests)
	{
		int n, x, y;
		readf !(" %s %s %s") (n, x, y);
		readln;
		auto a = readln.splitter.map !(to !(int)).array;

		int [int] b;
		foreach (ref t; a)
		{
			b[t] += 1;
		}
		auto c = b.byPair.array;
		c.schwartzSort !(q{-a.value});
		y -= x;

		int [] inPlace;
		while (x > 0)
		{
			int cur = c.front.value;
			auto d = c;
			while (x > 0 && !d.empty && d.front.value == cur)
			{
				inPlace ~= d.front.key;
				d.front.value -= 1;
				d.popFront ();
				x -= 1;
			}
		}

		int notFound = 1;
		while (notFound in b)
		{
			notFound += 1;
		}

		c.schwartzSort !(q{-a.value});

		int [] left;
		foreach (ref p; c)
		{
			foreach (i; 0..p.value)
			{
				left ~= p.key;
			}
		}

		int [2] [] trans;
		int len = left.length.to !(int);
		int hi = c.front.value % (len + !len);
		foreach (lo; 0..len)
		{
			int dest = (y > 0) ? left[lo] : notFound;
			y -= 1;
			trans ~= [left[hi], dest];
			hi = (hi + 1) % (len + !len);
		}

		if (trans.any !(p => p[0] == p[1]))
		{
			writeln ("NO");
			continue multitest_loop;
		}

		sort (inPlace);
		sort (trans);
		auto q = n.iota.array;
		makeIndex (a, q);
		auto res = new int [n];
		foreach (i; q)
		{
			if (!inPlace.empty && inPlace.front == a[i])
			{
				res[i] = a[i];
				inPlace.popFront ();
			}
			else if (!trans.empty && trans.front[0] == a[i])
			{
				res[i] = trans.front[1];
				trans.popFront ();
			}
			else
			{
				assert (false);
			}
		}
		writeln ("YES");
		writefln !("%(%s %)") (res);
	}
}


void main() { runSolver(); }

void problem() {
  auto QN = scan!int;

  auto solve() {
    auto subSolve() {
      auto N = scan!int;
      auto A = scan!int(N);

      auto rbt = A.redBlackTree;
      auto uf = UnionFind(N + 1);
      int rest = N;

      int last;
      foreach(a; A) {
        if (last < a) {
          foreach(other; rbt.lowerBound(a)) {
            if (!uf.same(a, other)) {
              rest--;
              uf.unite(a, other);
            }
          }
        }
        rbt.removeKey(a);
        if (rest == 1) break;
        last = max(last, a);
      }

      return rest;
    }

    foreach(i; 0..QN) {
      subSolve().writeln;
    }
  }

  outputForAtCoder(&solve);
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric, std.traits, std.functional, std.bigint, std.datetime.stopwatch, core.time, core.bitop;
T[][] combinations(T)(T[] s, in long m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(long n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");
Point invert(Point p) { return Point(p.y, p.x); }
long[] divisors(long n) { long[] ret; for (long i = 1; i * i <= n; i++) { if (n % i == 0) { ret ~= i; if (i * i != n) ret ~= n / i; } } return ret.sort.array; }
bool chmin(T)(ref T a, T b) { if (b < a) { a = b; return true; } else return false; }
bool chmax(T)(ref T a, T b) { if (b > a) { a = b; return true; } else return false; }
string charSort(alias S = "a < b")(string s) { return (cast(char[])((cast(byte[])s).sort!S.array)).to!string; }
ulong comb(ulong a, ulong b) { if (b == 0) {return 1;}else{return comb(a - 1, b - 1) * a / b;}}
T[] compress(T)(T[] arr, T origin = T.init) { T[T] indecies; arr.dup.sort.uniq.enumerate(origin).each!((i, t) => indecies[t] = i); return arr.map!(t => indecies[t]).array; }
string toAnswerString(R)(R r) { return r.map!"a.to!string".joiner(" ").array.to!string; }
struct ModInt(uint MD) if (MD < int.max) {ulong v;this(string v) {this(v.to!long);}this(int v) {this(long(v));}this(long v) {this.v = (v%MD+MD)%MD;}void opAssign(long t) {v = (t%MD+MD)%MD;}static auto normS(ulong x) {return (x<MD)?x:x-MD;}static auto make(ulong x) {ModInt m; m.v = x; return m;}auto opBinary(string op:"+")(ModInt r) const {return make(normS(v+r.v));}auto opBinary(string op:"-")(ModInt r) const {return make(normS(v+MD-r.v));}auto opBinary(string op:"*")(ModInt r) const {return make((ulong(v)*r.v%MD).to!ulong);}auto opBinary(string op:"^^", T)(T r) const {long x=v;long y=1;while(r){if(r%2==1)y=(y*x)%MD;x=x^^2%MD;r/=2;} return make(y);}auto opBinary(string op:"/")(ModInt r) const {return this*memoize!inv(r);}static ModInt inv(ModInt x) {return x^^(MD-2);}string toString() const {return v.to!string;}auto opOpAssign(string op)(ModInt r) {return mixin ("this=this"~op~"r");}}
alias MInt1 = ModInt!(10^^9 + 7);
alias MInt9 = ModInt!(998_244_353);
void outputForAtCoder(T)(T delegate() fn) {
  static if (is(T == float) || is(T == double) || is(T == real)) "%.16f".writefln(fn());
  else static if (is(T == void)) fn();
  else static if (is(T == string)) fn().writeln;
  else static if (isInputRange!T) {
    static if (!is(string == ElementType!T) && isInputRange!(ElementType!T)) foreach(r; fn()) r.toAnswerString.writeln;
    else foreach(r; fn()) r.writeln;
  }
  else fn().writeln;
}
void runSolver() {
  enum BORDER = "==================================";
  debug { BORDER.writeln; while(!stdin.eof) { "<<< Process time: %s >>>".writefln(benchmark!problem(1)); BORDER.writeln; } }
  else problem();
}
enum YESNO = [true: "Yes", false: "No"];

// -----------------------------------------------

struct UnionFind {
  int[] parent;

  this(int size) {
    parent.length = size;
    foreach(i; 0..size) parent[i] = i;
  }

  int root(int x) {
    if (parent[x] == x) return x;
    return parent[x] = root(parent[x]);
  }

  int unite(int x, int y) {
    int rootX = root(x);
    int rootY = root(y);

    if (rootX == rootY) return rootY;
    return parent[rootX] = rootY;
  }

  bool same(int x, int y) {
    int rootX = root(x);
    int rootY = root(y);

    return rootX == rootY;
  }
}

void main() { runSolver(); }

void problem() {
  auto QN = scan!int;

  auto solve() {
    auto subSolve() {
      auto N = scan!int;
      auto A = scan!int(N);

      auto rbt = A.redBlackTree;
      auto uf = UnionFind(N + 1);
      int rest = N;

      foreach(a; A) {
        foreach(other; rbt.lowerBound(a)) {
          if (!uf.same(a, other)) {
            rest--;
            uf.unite(a, other);
          }
        }
        rbt.removeKey(a);
        if (rest == 1) break;
      }

      return rest;
    }

    foreach(i; 0..QN) {
      subSolve().writeln;
    }
  }

  outputForAtCoder(&solve);
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric, std.traits, std.functional, std.bigint, std.datetime.stopwatch, core.time, core.bitop;
T[][] combinations(T)(T[] s, in long m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(long n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");
Point invert(Point p) { return Point(p.y, p.x); }
long[] divisors(long n) { long[] ret; for (long i = 1; i * i <= n; i++) { if (n % i == 0) { ret ~= i; if (i * i != n) ret ~= n / i; } } return ret.sort.array; }
bool chmin(T)(ref T a, T b) { if (b < a) { a = b; return true; } else return false; }
bool chmax(T)(ref T a, T b) { if (b > a) { a = b; return true; } else return false; }
string charSort(alias S = "a < b")(string s) { return (cast(char[])((cast(byte[])s).sort!S.array)).to!string; }
ulong comb(ulong a, ulong b) { if (b == 0) {return 1;}else{return comb(a - 1, b - 1) * a / b;}}
T[] compress(T)(T[] arr, T origin = T.init) { T[T] indecies; arr.dup.sort.uniq.enumerate(origin).each!((i, t) => indecies[t] = i); return arr.map!(t => indecies[t]).array; }
string toAnswerString(R)(R r) { return r.map!"a.to!string".joiner(" ").array.to!string; }
struct ModInt(uint MD) if (MD < int.max) {ulong v;this(string v) {this(v.to!long);}this(int v) {this(long(v));}this(long v) {this.v = (v%MD+MD)%MD;}void opAssign(long t) {v = (t%MD+MD)%MD;}static auto normS(ulong x) {return (x<MD)?x:x-MD;}static auto make(ulong x) {ModInt m; m.v = x; return m;}auto opBinary(string op:"+")(ModInt r) const {return make(normS(v+r.v));}auto opBinary(string op:"-")(ModInt r) const {return make(normS(v+MD-r.v));}auto opBinary(string op:"*")(ModInt r) const {return make((ulong(v)*r.v%MD).to!ulong);}auto opBinary(string op:"^^", T)(T r) const {long x=v;long y=1;while(r){if(r%2==1)y=(y*x)%MD;x=x^^2%MD;r/=2;} return make(y);}auto opBinary(string op:"/")(ModInt r) const {return this*memoize!inv(r);}static ModInt inv(ModInt x) {return x^^(MD-2);}string toString() const {return v.to!string;}auto opOpAssign(string op)(ModInt r) {return mixin ("this=this"~op~"r");}}
alias MInt1 = ModInt!(10^^9 + 7);
alias MInt9 = ModInt!(998_244_353);
void outputForAtCoder(T)(T delegate() fn) {
  static if (is(T == float) || is(T == double) || is(T == real)) "%.16f".writefln(fn());
  else static if (is(T == void)) fn();
  else static if (is(T == string)) fn().writeln;
  else static if (isInputRange!T) {
    static if (!is(string == ElementType!T) && isInputRange!(ElementType!T)) foreach(r; fn()) r.toAnswerString.writeln;
    else foreach(r; fn()) r.writeln;
  }
  else fn().writeln;
}
void runSolver() {
  enum BORDER = "==================================";
  debug { BORDER.writeln; while(!stdin.eof) { "<<< Process time: %s >>>".writefln(benchmark!problem(1)); BORDER.writeln; } }
  else problem();
}
enum YESNO = [true: "Yes", false: "No"];

// -----------------------------------------------

struct UnionFind {
  int[] parent;

  this(int size) {
    parent.length = size;
    foreach(i; 0..size) parent[i] = i;
  }

  int root(int x) {
    if (parent[x] == x) return x;
    return parent[x] = root(parent[x]);
  }

  int unite(int x, int y) {
    int rootX = root(x);
    int rootY = root(y);

    if (rootX == rootY) return rootY;
    return parent[rootX] = rootY;
  }

  bool same(int x, int y) {
    int rootX = root(x);
    int rootY = root(y);

    return rootX == rootY;
  }
}

import std.stdio, std.string, std.conv;
import std.algorithm.iteration;
import std.algorithm.searching;
import std.algorithm.mutation;
import std.range;
import std.typecons;
ulong prefsum(int n)
{
    return (cast(ulong) n*(n + 1)) / 2;
}
ulong segsum(int from, int to) {
    return prefsum(to) - prefsum(from - 1);
}
void solution(ref File input, ref File output) {
    auto t = input.readln.chomp.to!int;
    while (t-- > 0) {
        auto _ = input.readln;
        auto source = input.readln.chomp
            .split(' ')
            .map!(to!int)
            .enumerate;
        int start = 1, answer;
        ulong sum = 0;
        foreach (item; source)
        {
            auto ind = cast(int) item[0] + 1, val = item[1];
            sum += val;
            //writeln("Start: ", start,
            //        "Current: ", ind,
            //        " Segsum", segsum(start, ind),
            //        "Sum: ", sum);
            if (segsum(start, ind) == sum)
            {
                start = ind + 1;
                sum = 0;
                answer += 1;
            }
        }
        output.writeln(answer);
    }
}
void main()
{
    File input, output;
    debug(1) {
        input = File("input.txt", "r");
        output = File("output.txt", "w");
    } else {
        input = stdin;
        output = stdout;
    }
    solution(input, output);
}

import std.stdio, std.string, std.conv;
import std.algorithm.iteration;
import std.algorithm.searching;
import std.algorithm.mutation;
import std.range;
import std.typecons;
int prefsum(int n)
{
    return (n*(n + 1)) / 2;
}
int segsum(int from, int to) {
    return prefsum(to) - prefsum(from - 1);
}
void solution(ref File input, ref File output) {
    auto t = input.readln.chomp.to!int;
    while (t-- > 0) {
        auto _ = input.readln;
        auto source = input.readln.chomp
            .split(' ')
            .map!(to!int)
            .enumerate;
        int start = 1, answer;
        ulong sum = 0;
        foreach (item; source)
        {
            auto ind = cast(int) item[0] + 1, val = item[1];
            sum += val;
            //writeln("Start: ", start,
            //        "Current: ", ind,
            //        " Segsum", segsum(start, ind),
            //        "Sum: ", sum);
            if (segsum(start, ind) == sum)
            {
                start = ind + 1;
                sum = 0;
                answer += 1;
            }
        }
        output.writeln(answer);
    }
}
void main()
{
    File input, output;
    debug(1) {
        input = File("input.txt", "r");
        output = File("output.txt", "w");
    } else {
        input = stdin;
        output = stdout;
    }
    solution(input, output);
}


// Cheese-Cracker: cheese-cracker.github.io

// Main Logic Here
void play(){
    ll n;
    n = rd;
    if(n == 1){
        writeln(0);
    }else if(n == 2){
        writeln(1);
    }else if (n == 3){
        writeln(2);
    }else if(n % 2 == 0){
        writeln(2);
    }else{
        writeln(3);
    }
}

int main(){
    long t = 1;
    t = rd;        // Toggle for testcases!
    while(t--) play();  // Let's play!
    return 0;
}

/**********That's All Folks!**********/
import std.stdio, std.conv, std.functional, std.string, std.algorithm;
import std.container, std.range, std.typecons, std.numeric, std.math, std.random;
static string[] inp;    // Read input
T rd(T = long)(){while(!inp.length) inp = readln.chomp.split; string a = inp[0]; inp.popFront; return a.to!T;}
T[] rdarr(T = long)(){ auto r = readln.chomp.split.to!(T[]); return r; }
alias ll = long;
alias tup = Tuple!(long, "x",  long, "y");
void show(A...)(A a) { debug{ foreach(t; a){ stderr.write(t, "| "); } stderr.writeln; } } // Debug
/* Add if TLE, T max(T = long)(T a, T b){ return (a > b) ? a : b; } */

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(ref long x, long y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto t = RD!int;
	auto ans = new long[](t);
	foreach (ti; 0..t)
	{
		auto n = RD;
		if (n == 1) continue;
		else if (n == 2)
			ans[ti] = 1;
		else if (n == 3)
			ans[ti] = 2;
		else if (n % 2 == 0)
			ans[ti] = 2;
		else
			ans[ti] = 3;
	}

	foreach (e; ans)
	{
		writeln(e);
	}
	stdout.flush;
	debug readln;
}

// Cheese-Cracker: cheese-cracker.github.io

ll[] primes;

void prime_sieve(int siz){
    auto isPrime = new bool[](siz+1);
    isPrime[] = 1;
    foreach(p; 2..10000){
        if(isPrime[p]){
            for(ll divi = p*p; divi <= siz; divi += p){
                isPrime[divi.to!int] = 0;
            }
        }
    }
    foreach(k; 2..siz+1){
        if(isPrime[k]) primes ~= k;
    }
}

// Main Logic Here
void play(){
    ll n;
    n = rd;
    ll tak = n;
    foreach(p; primes){
        if(n % p == 0){
            tak = p;
            break;
        }
    }
    writeln(tak - (tak == n));
}

int main(){
    long t = 1;
    prime_sieve(100000);
    t = rd;        // Toggle for testcases!
    while(t--) play();  // Let's play!
    return 0;
}

/**********That's All Folks!**********/
import std.stdio, std.conv, std.functional, std.string, std.algorithm;
import std.container, std.range, std.typecons, std.numeric, std.math, std.random;
static string[] inp;    // Read input
T rd(T = long)(){while(!inp.length) inp = readln.chomp.split; string a = inp[0]; inp.popFront; return a.to!T;}
T[] rdarr(T = long)(){ auto r = readln.chomp.split.to!(T[]); return r; }
alias ll = long;
alias tup = Tuple!(long, "x",  long, "y");
void show(A...)(A a) { debug{ foreach(t; a){ stderr.write(t, "| "); } stderr.writeln; } } // Debug
/* Add if TLE, T max(T = long)(T a, T b){ return (a > b) ? a : b; } */

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(ref long x, long y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto t = RD!int;
	auto ans = new long[](t);
	foreach (ti; 0..t)
	{
		auto n = RD;
		while (n != 1)
		{
			bool ok;
			for (long i = 2; i*i <= n; ++i)
			{
				if (n % i) continue;
				n = i;
				ok = true;
				break;
			}
			if (!ok)
				--n;
			++ans[ti];
		}
	}

	foreach (e; ans)
	{
		writeln(e);
	}
	stdout.flush;
	debug readln;
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(ref long x, long y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto t = RD!int;
	auto ans = new long[](t);
	foreach (ti; 0..t)
	{
		auto n = RD;
		while (n != 1)
		{
			if (n == 2)
			{
				++ans[ti];
				break;
			}
			bool ok;
			for (long i = 2; i*i <= n; ++i)
			{
				if (n % i) continue;
				n = i;
				ok = true;
				break;
			}
			if (!ok)
				--n;
			++ans[ti];
		}
	}

	foreach (e; ans)
	{
		writeln(e);
	}
	stdout.flush;
	debug readln;
}


import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto n = RD!int;
	auto a = RDA;
	auto b1 = new long[](n);
	auto b2 = new long[](n);
	foreach (i; 0..n)
	{
		long[] nums;
		auto x = a[i];
		while (x != 0)
		{
			nums ~= x % 10;
			x /= 10;
		}
		debug writeln(nums);
		foreach (j; 0..nums.length)
		{
			auto tmp = nums[j];
			foreach (k; 0..j+j)
			{
				tmp.modm(10);
			}
			b2[i].moda(tmp);
			tmp.modm(10);
			b1[i].moda(tmp);
		}
	}
	debug writeln(b1);
	debug writeln(b2);

	long ans;
	foreach (i; 0..n)
	{
		auto x = b1[i] + b2[i];
		x.modm(n);
		ans.moda(x);
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

import std.stdio;

auto calc(long x) {
    long base = 1;
    long result = 0;
    while(x > 0) {
        auto d = x % 10;
        x = x / 10;
        result += d * base;
        base *= 100;
    }
    return result;
}

void main() {
    int MOD = 998244353;
    int n;
    long a, result;

    readf(" %s", n);
    foreach(i; 0..n) {
        readf(" %s", a);
        auto b = calc(a) % MOD;
        result += (b * 10 * n) % MOD + (b * n) % MOD;
        result %= MOD;
    }
    writeln(result);
}

import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

const long mod = 998_244_353;

void solve(){
	int n = read.to!int;

	long[] as;
	foreach(i; 0 .. n) as ~= read.to!long;

	long[][] ws;
	foreach(a; as){
		long [] w;
		for(long x = a; x > 0; x /= 10) w ~= x % 10;
		ws ~= w;
	}

	long ans;
	foreach(w; ws){
		int i = 0;
		long m = 1;
		for(; i < w.length; i += 1, m *= 100, m %= mod){
			ans += w[i] * 11 * m * n % mod;
			ans %= mod;
		}
	}

	ans.writeln;
}


module main;

import std.c.stdio;
import std.algorithm.sorting;

int temp(int a, int b)
{
    while(b > 0) {
        int temp = b;
        b = a % b;
        a = temp;
    }
    return a;
}

int main(string[] argv)
{
    int n, res = 0;
    scanf("%d", &n);
    int[] arr = new int[n];
    for(int i = 0; i < n; i++)
        scanf("%d", &arr[i]);
    arr.sort();
    int mGcd = arr[1] - arr[0];
    for(int i = 2; i < n; i++) {
        mGcd = temp(mGcd, arr[i] - arr[i-1]);
    }

    for(int i = 1; i < n; i++) {
        res += (arr[i]-arr[i-1]) / mGcd - 1;
    }

    printf("%d\n", res);

	return 0;
}

module main;

import std.c.stdio;
import std.algorithm;

long gcd(long a, long b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	int [] a = new int[n];
	for(int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a);
	long m = 0;
	for(int i = 0; i < n-1; ++i) {
	    m = gcd(a[i+1]-a[i], m);
	}
	long add = 0;
	for(int i = 0; i < n-1; ++i) {
	    add += (a[i+1]-a[i]) / m - 1;
	}
	printf("%d\n", add);
	return 0;
}

module main;
import core.stdc.stdio;
import std.algorithm;

int gcd(int a, int b){
while (a > 0 && b > 0){
if (a > b){
a = a % b;
} else {
b = b % a;
}
}
return a + b;
}

int main(string[] argv)
{
int n;
scanf("%d", &n);
int [] arr = new int[n];
for(int i = 0; i<n; i++)
scanf("%d", &arr[i]);
arr.sort!();
int cur = arr[1] - arr[0];
for (int i = 1; i < n; i++){
cur = gcd(cur, arr[i] - arr[i - 1]);
}
int ans = 0;
for (int i = 1; i < n; i++){
int len = arr[i] - arr[i - 1];
ans += len / cur - 1;
}
printf("%d", ans);
return 0;
}

module main;

import core.stdc.stdio;
import std.algorithm.sorting;
import std.algorithm.comparison;
import std.numeric;

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n];
	int mina=1000000001, maxa =-1000000001;
	for(int i = 0; i<n; i++){
		scanf("%d", &arr[i]);
		if (mina > arr[i]){
		    mina = arr[i];
		}
		if (maxa < arr[i]){
		    maxa = arr[i];
		}
	}
	sort(arr);

	int diff = maxa - mina;
	for(int i = 0; i<n-1; i++)
		diff = gcd(diff,arr[i+1]-arr[i]);
	//printf("%d %d %d\n", mina, maxa, diff);
    if ((maxa - mina)==0) {
        printf("%d\n", 0);
    }
	else
	    printf("%d\n", (maxa-mina)/gcd(mina-maxa,diff)+1-n);
	return 0;
}

module main;
import std.algorithm;
import std.c.stdio;
int Gcd(int a, int b){
	if(b==0)
		return a;
	return Gcd(b, a%b);
}

int s;
int main ()
{
    int n, i;
    scanf("%d", &n);
    int []a = new int [n];
int []d = new int [n];
    for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    }

    a.sort();
    for (i = 1; i < n; i++) {
        d[i] = a[i] - a[i-1];
    }
    int gcd = d[1];
    for(i = 2; i < n; i++) {
        gcd = Gcd(gcd, d[i]);
    }
    for (i = 1; i < n; i++) {
        s += (d[i]/gcd) - 1;
    }
    printf("%d",s);
    return 0;
}

import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.datetime.stopwatch;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;

    auto arr = readln.chomp.split.map!(to!int).array;

    arr.sort();

    auto dst = zip(arr, arr.dropOne).map!(t => t[1] - t[0]).array;

    auto gcd = dst.fold!gcd;

    debug { dst.writeln; gcd.writeln; }

    int ans = 0;
    foreach (a, b; lockstep(arr, arr.dropOne)) {
        ans += (b - a) / gcd - 1;
    }

    ans.writeln;
}

module main;

import core.stdc.stdio;
import std.algorithm.sorting;

int gcd (int a, int b) {
	if (b == 0)
		return a;
	else
		return gcd (b, a % b);
}

int main(string[] argv)
{
	int n;

	scanf("%d", &n);
	int [] a = new int[n];
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	a.sort();
	int small = a[1] - a[0];
	for(int i = 1; i < n - 1; i++)
	    small = gcd(small, a[i + 1] - a[i]);

	printf("%d", (a[n - 1] - a[0]) / small - n + 1);

	return 0;
}

module main;

import std.c.stdio;
import std.algorithm;

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

int main(string[] argv)
{
    int n;
    scanf("%d", &n);
    auto arr = new int[n];
    for(int i = 0; i<n; i++)
        scanf("%d", &arr[i]);

    sort(arr);

    int g = 0;
    for (int i = 1; i < n; i++) {
        g = gcd(arr[i] - arr[i-1], g);
    }

    int ret = 0;
    for (int i = 1; i < n; i++) {
        ret += (arr[i] - arr[i-1]) / g - 1;
    }

    printf("%d\n", ret);
    return 0;
}

module main;

import std.c.stdio;
import std.algorithm;
import std.range;
import std.numeric;

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	sort(arr);
	int q = arr[1]-arr[0];
	for(int i = 2; i<n; i++)
		q = gcd(arr[i]-arr[i-1], q);

	//printf("%d\n", q);
	int ans = 0;
	for(int i = 1; i<n; i++) {
	    ans += ((arr[i]-arr[i-1])/q - 1);
	}
	printf("%d", ans);
	return 0;
}

module main;

import std.c.stdio;
import std.algorithm;

int main(string[] argv)
{
	int n;
	int mn = 2000006789;
	scanf("%d", &n);
	int [] a = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &a[i]);
    a.sort();

    int m = a[1] - a[0];
    for (int i = 1; i * i <= m; i++) if (m % i == 0){
        int dist = i, flag = 0, res = 0;
        for (int j = 1; j < n; j++){
            if ((a[j] - a[j - 1]) % dist != 0) flag = 1;
            res += (a[j] - a[j - 1]) / dist - 1;
        }
        if (res < mn && flag == 0) mn = res;

        dist = m / i, flag = 0, res = 0;
        for (int j = 1; j < n; j++){
            if ((a[j] - a[j - 1]) % dist != 0) flag = 1;
            res += (a[j] - a[j - 1]) / dist - 1;
        }
        if (res < mn && flag == 0) mn = res;
    }
	printf("%d", mn);
	return 0;
}

import std.stdio;
import std.c.stdio;
import std.algorithm.sorting;
import std.numeric;
void main()
{
    int n;
    scanf("%d", &n);
    int[] a = new int[n];
    for(int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    a.sort();

    int g = a[1] - a[0];
    for(int i = 2; i < n; i++){
        g = gcd(g, a[i] - a[i-1]);
    }
    int u = a[n-1]-a[0];
    int x = u/g;
    int res = x-n+1;
    printf("%d", res);

}

import std.stdio, std.conv, std.container, std.algorithm;

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

void main() {
 int n;
 scanf("%d", &n);
 Array!int a;
 for (int i = 0; i < n; ++i) {
	int temp = 0;
	scanf("%d", &temp);
	a.insertBack(temp);
 }

 a[].sort();
 int dist = a[1] - a[0], ans = 0;
 for (int i = 2; i < n; ++i)
	dist = gcd(dist, a[i] - a[i - 1]);
 for (int i = 1; i < n; ++i)
	ans += (a[i] - a[i - 1]) / dist - 1;
 printf("%d", ans);

}

module main;

import std.c.stdio;

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

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	//printf("%d", gcd(0,4));
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	int mx = -1000000001, mn = 2000000001;
	for(int i = 0; i<n; i++) {
	    if(mx < arr[i])
	        mx = arr[i];
	    if(mn > arr[i])
	        mn = arr[i];
	}
	for(int i = 0; i<n; i++)
	    arr[i] -= mn;
	int g = gcd(arr[0],arr[1]);
	for(int i = 2; i<n; i++)
		g = gcd(g, arr[i]);

	//printf("%d", g);
	printf("%d", (mx - mn)/g + 1 - n);
	return 0;
}

module main;

import std.c.stdio;
import std.algorithm : sort;

int main(string[] argv)
{
    int n;
    scanf("%d", &n);
    int[] x = new int[n];
    for(int i = 0; i < n; i++)
        scanf("%d", &x[i]);
    sort(x);
    int g = 0;
    for (int i = 1; i < n; i++) {
        int a = x[i] - x[i - 1];
        int b = g;
        while (b > 0) {
            a %= b;
            int t = b;
            b = a;
            a = t;
        }
        g = a;
    }
    int mi = 2000000000;
    int ma = -2000000000;
    for (int i = 0; i < n; ++i) {
        if (mi > x[i]) mi = x[i];
        if (ma < x[i]) ma = x[i];
    }
    int diff = ma - mi;
    diff /= g;
    printf("%d\n", diff + 1 - n);
    return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
    int n;
    scanf("%d", &n);
    int [] x = new int[n];
    for(int i = 0; i < n; i++)
        scanf("%d", &x[i]);
    int g = 0;
    for (int i = 0; i < n - 1; i++) {
        int a = x[i] - x[i - 1];
        if (a < 0) a = -a;
        int b = g;
        while (b > 0) {
            a %= b;
            int t = b;
            b = a;
            a = t;
        }
        g = a;
    }
    int mi = 2000000000;
    int ma = -2000000000;
    for (int i = 0; i < n; ++i) {
        if (mi > x[i]) mi = x[i];
        if (ma < x[i]) ma = x[i];
    }
    int diff = ma - mi;
    diff /= g;
    printf("%d\n", diff + 1 - n);
    return 0;
}

module main;

import core.stdc.stdio;
import std.algorithm.sorting;
import std.algorithm.comparison;
import std.numeric;

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n];
	int mina=1000000001, maxa =-1000000001;
	for(int i = 0; i<n; i++){
		scanf("%d", &arr[i]);
		if (mina > arr[i]){
		    mina = arr[i];
		}
		if (maxa < arr[i]){
		    maxa = arr[i];
		}
	}
	sort(arr);

	int diff = maxa - mina;
	for(int i = 0; i<n-1; i++)
		if (diff >arr[i+1]-arr[i]){
		    diff = arr[i+1]-arr[i];
		}
	printf("%d\n", (maxa-mina)/gcd(mina-maxa,diff)+1-n);
	return 0;
}

module main;

import core.stdc.stdio;
import std.algorithm.sorting;
import std.algorithm.comparison;
import std.numeric;

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n];
	int mina=1000000001, maxa =-1000000001;
	for(int i = 0; i<n; i++){
		scanf("%d", &arr[i]);
		if (mina > arr[i]){
		    mina = arr[i];
		}
		if (maxa < arr[i]){
		    maxa = arr[i];
		}
	}
	sort(arr);

	int diff = maxa - mina;
	for(int i = 0; i<n-1; i++)
		if (diff >arr[i+1]-arr[i]){
		    diff = arr[i+1]-arr[i];
		}
    if (diff ==0) {
        printf("%d\n", 0);
    }
	else
	    printf("%d\n", (maxa-mina)/gcd(mina-maxa,diff)+1-n);
	return 0;
}

module main;

import core.stdc.stdio;
import std.algorithm.sorting;

int main(string[] argv)
{
	int n;

	scanf("%d", &n);
	int [] a = new int[n];
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	a.sort();
	int small = 2000000012;
	for(int i = 0; i < n - 1; i++)
	    if (a[i + 1] - a[i] < small)
	        small = a[i + 1] - a[i];

	printf("%d", (a[n - 1] - a[0]) / small - n + 1);

	return 0;
}

module main;

import std.c.stdio;

int gcd (int a, int b) {
    if(a < 0)
    a *= -1;
    if(b < 0)
    b *= -1;
	return b ? gcd (b, a % b) : a;
}

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	//printf("%d", gcd(1,10));
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	int g = gcd(arr[0],arr[1]);
	for(int i = 0; i<n; i++)
		g = gcd(g, arr[i]);
	int mx = -1000000001, mn = 1000000001;
	for(int i = 0; i<n; i++) {
	    if(mx < arr[i])
	        mx = arr[i];
	    if(mn > arr[i])
	        mn = arr[i];
	}
	//printf("%d", g);
	printf("%d", (mx - mn)/g + 1 - n);
	return 0;
}

module main;

import std.c.stdio;

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

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	//printf("%d", gcd(1,10));
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	for(int i = 0; i<n; i++)
	    arr[i] += 1000000000;
	int g = gcd(arr[0],arr[1]);
	for(int i = 0; i<n; i++)
		g = gcd(g, arr[i]);
	int mx = 0, mn = 2000000001;
	for(int i = 0; i<n; i++) {
	    if(mx < arr[i])
	        mx = arr[i];
	    if(mn > arr[i])
	        mn = arr[i];
	}
	//printf("%d", g);
	printf("%d", (mx - mn)/g + 1 - n);
	return 0;
}

module main;

import std.c.stdio;
import std.algorithm;

int main(string[] argv)
{
	int n;
	int mn = 1123456789;
	scanf("%d", &n);
	int [] a = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &a[i]);
    a.sort();

    int m = a[1] - a[0];
    for (int i = 1; i * i <= m; i++) if (m % i == 0){
        int dist = i, flag = 0, res = 0;
        for (int j = 1; j < n; j++){
            if ((a[j] - a[j - 1]) % dist != 0) flag = 1;
            res += (a[j] - a[j - 1]) / dist - 1;
        }
        if (res < mn && flag == 0) mn = res;

        dist = m / i, flag = 0, res = 0;
        for (int j = 1; j < n; j++){
            if ((a[j] - a[j - 1]) % dist != 0) flag = 1;
            res += (a[j] - a[j - 1]) / dist - 1;
        }
        if (res < mn && flag == 0) mn = res;
    }
	printf("%d", mn);
	return 0;
}