#include <algorithm>
#include <cassert>
#include <chrono>
#include <iostream>
#include <random>
#include <vector>
using namespace std;

namespace IO {
    const int BUFFER_SIZE = 1 << 15;

    char input_buffer[BUFFER_SIZE];
    int input_pos = 0, input_len = 0;

    char output_buffer[BUFFER_SIZE];
    int output_pos = 0;

    char number_buffer[100];
    uint8_t lookup[100];

    void _update_input_buffer() {
        input_len = fread(input_buffer, sizeof(char), BUFFER_SIZE, stdin);
        input_pos = 0;

        if (input_len == 0)
            input_buffer[0] = EOF;
    }

    inline char next_char(bool advance = true) {
        if (input_pos >= input_len)
            _update_input_buffer();

        return input_buffer[advance ? input_pos++ : input_pos];
    }

    template<typename T>
    inline void read_int(T &number) {
        bool negative = false;
        number = 0;

        while (!isdigit(next_char(false)))
            if (next_char() == '-')
                negative = true;

        do {
            number = 10 * number + (next_char() - '0');
        } while (isdigit(next_char(false)));

        if (negative)
            number = -number;
    }

    template<typename T, typename... Args>
    inline void read_int(T &number, Args &... args) {
        read_int(number);
        read_int(args...);
    }

    void _flush_output() {
        fwrite(output_buffer, sizeof(char), output_pos, stdout);
        output_pos = 0;
    }

    inline void write_char(char c) {
        if (output_pos == BUFFER_SIZE)
            _flush_output();

        output_buffer[output_pos++] = c;
    }

    template<typename T>
    inline void write_int(T number, char after = '\0') {
        if (number < 0) {
            write_char('-');
            number = -number;
        }

        int length = 0;

        while (number >= 10) {
            uint8_t lookup_value = lookup[number % 100];
            number /= 100;
            number_buffer[length++] = (lookup_value & 15) + '0';
            number_buffer[length++] = (lookup_value >> 4) + '0';
        }

        if (number != 0 || length == 0)
            write_char(number + '0');

        for (int i = length - 1; i >= 0; i--)
            write_char(number_buffer[i]);

        if (after)
            write_char(after);
    }

    void init() {
        // Make sure _flush_output() is called at the end of the program.
        bool exit_success = atexit(_flush_output) == 0;
        assert(exit_success);

        for (int i = 0; i < 100; i++)
            lookup[i] = (i / 10 << 4) + i % 10;
    }
}

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count() * ((uint64_t) new char | 1));

const int BITS = 18;

template<typename T>
struct xor_basis {
    // A list of basis values sorted in decreasing order, where each value has a unique highest bit.
    // We use a static array instead of a vector for better performance.
    T basis[BITS];
    int n = 0;

    T min_value(T start) const {
        for (int i = 0; i < n; i++)
            start = min(start, start ^ basis[i]);

        return start;
    }

    T max_value(T start = 0) const {
        for (int i = 0; i < n; i++)
            start = max(start, start ^ basis[i]);

        return start;
    }

    bool add(T x) {
        if (n == BITS)
            return false;

        x = min_value(x);

        if (x == 0)
            return false;

        basis[n++] = x;

        // Insertion sort.
        for (int k = n - 1; k > 0 && basis[k] > basis[k - 1]; k--)
            swap(basis[k], basis[k - 1]);

        return true;
    }

    void merge(const xor_basis<T> &other) {
        for (int i = 0; i < other.n && n < BITS; i++)
            add(other.basis[i]);
    }

    void merge(const xor_basis<T> &a, const xor_basis<T> &b) {
        *this = a;
        merge(b);
    }
};

int main() {
    IO::init();

    int N;
    IO::read_int(N);
    vector<int> S(N);

    for (int &s : S)
        IO::read_int(s);

    shuffle(S.begin(), S.end(), rng);
    vector<int> original;

    for (int bits = BITS; bits >= 0; bits--) {
        xor_basis<int> basis;
        original.clear();

        for (int s : S)
            if (s < 1 << bits && basis.add(s))
                original.push_back(s);

        if ((int) original.size() == bits)
            break;
    }

    int bits = original.size();
    vector<int> permutation = {0};
    int number = 0;

    for (int i = 1; i < 1 << bits; i++) {
        number ^= original[__builtin_ctz(i)];
        permutation.push_back(number);
    }

    IO::write_int(bits, '\n');

    for (int i = 0; i < 1 << bits; i++)
        IO::write_int(permutation[i], i < (1 << bits) - 1 ? ' ' : '\n');
}


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

const int BITS = 18;

template<typename T>
struct xor_basis {
    // A list of basis values sorted in decreasing order, where each value has a unique highest bit.
    // We use a static array instead of a vector for better performance.
    T basis[BITS];
    int n = 0;

    T min_value(T start) const {
        for (int i = 0; i < n; i++)
            start = min(start, start ^ basis[i]);

        return start;
    }

    T max_value(T start = 0) const {
        for (int i = 0; i < n; i++)
            start = max(start, start ^ basis[i]);

        return start;
    }

    bool add(T x) {
        if (n == BITS)
            return false;

        x = min_value(x);

        if (x == 0)
            return false;

        basis[n++] = x;

        // Insertion sort.
        for (int k = n - 1; k > 0 && basis[k] > basis[k - 1]; k--)
            swap(basis[k], basis[k - 1]);

        return true;
    }

    void merge(const xor_basis<T> &other) {
        for (int i = 0; i < other.n && n < BITS; i++)
            add(other.basis[i]);
    }

    void merge(const xor_basis<T> &a, const xor_basis<T> &b) {
        *this = a;
        merge(b);
    }
};

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

    int N;
    cin >> N;
    vector<int> S(N);

    for (int &s : S)
        cin >> s;

    vector<int> original;

    for (int bits = BITS; bits >= 0; bits--) {
        xor_basis<int> basis;
        original.clear();

        for (int s : S)
            if (s < 1 << bits && basis.add(s))
                original.push_back(s);

        if ((int) original.size() == bits)
            break;
    }

    int bits = original.size();
    vector<int> permutation = {0};
    int number = 0;

    for (int i = 1; i < 1 << bits; i++) {
        number ^= original[__builtin_ctz(i)];
        permutation.push_back(number);
    }

    cout << bits << '\n';

    for (int i = 0; i < 1 << bits; i++)
        cout << permutation[i] << (i < (1 << bits) - 1 ? ' ' : '\n');
}


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

const int BITS = 18;

template<typename T>
struct xor_basis {
    // A list of basis values sorted in decreasing order, where each value has a unique highest bit.
    // We use a static array instead of a vector for better performance.
    T basis[BITS];
    int n = 0;

    T min_value(T start) const {
        for (int i = 0; i < n; i++)
            start = min(start, start ^ basis[i]);

        return start;
    }

    T max_value(T start = 0) const {
        for (int i = 0; i < n; i++)
            start = max(start, start ^ basis[i]);

        return start;
    }

    bool add(T x) {
        if (n == BITS)
            return false;

        x = min_value(x);

        if (x == 0)
            return false;

        basis[n++] = x;

        // Insertion sort.
        for (int k = n - 1; k > 0 && basis[k] > basis[k - 1]; k--)
            swap(basis[k], basis[k - 1]);

        return true;
    }

    void merge(const xor_basis<T> &other) {
        for (int i = 0; i < other.n && n < BITS; i++)
            add(other.basis[i]);
    }

    void merge(const xor_basis<T> &a, const xor_basis<T> &b) {
        *this = a;
        merge(b);
    }
};

int N;
vector<int> S;

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

    cin >> N;
    S.resize(N);

    for (int &s : S)
        cin >> s;

    vector<int> original;

    for (int bits = BITS; bits >= 0; bits--) {
        xor_basis<int> basis;
        original.clear();

        for (int s : S)
            if (s < 1 << bits && basis.add(s))
                original.push_back(s);

        if ((int) original.size() == bits)
            break;
    }

    int bits = original.size();
    vector<int> permutation = {0};
    int number = 0;

    for (int i = 1; i < 1 << bits; i++) {
        number ^= original[__builtin_ctz(i)];
        permutation.push_back(number);
    }

    cout << bits << '\n';

    for (int i = 0; i < 1 << bits; i++)
        cout << permutation[i] << (i < (1 << bits) - 1 ? ' ' : '\n');
}


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

namespace IO {
    const int BUFFER_SIZE = 1 << 15;

    char input_buffer[BUFFER_SIZE];
    int input_pos = 0, input_len = 0;

    char output_buffer[BUFFER_SIZE];
    int output_pos = 0;

    char number_buffer[100];
    uint8_t lookup[100];

    void _update_input_buffer() {
        input_len = fread(input_buffer, sizeof(char), BUFFER_SIZE, stdin);
        input_pos = 0;

        if (input_len == 0)
            input_buffer[0] = EOF;
    }

    inline char next_char(bool advance = true) {
        if (input_pos >= input_len)
            _update_input_buffer();

        return input_buffer[advance ? input_pos++ : input_pos];
    }

    template<typename T>
    inline void read_int(T &number) {
        bool negative = false;
        number = 0;

        while (!isdigit(next_char(false)))
            if (next_char() == '-')
                negative = true;

        do {
            number = 10 * number + (next_char() - '0');
        } while (isdigit(next_char(false)));

        if (negative)
            number = -number;
    }

    template<typename T, typename... Args>
    inline void read_int(T &number, Args &... args) {
        read_int(number);
        read_int(args...);
    }

    void _flush_output() {
        fwrite(output_buffer, sizeof(char), output_pos, stdout);
        output_pos = 0;
    }

    inline void write_char(char c) {
        if (output_pos == BUFFER_SIZE)
            _flush_output();

        output_buffer[output_pos++] = c;
    }

    template<typename T>
    inline void write_int(T number, char after = '\0') {
        if (number < 0) {
            write_char('-');
            number = -number;
        }

        int length = 0;

        while (number >= 10) {
            uint8_t lookup_value = lookup[number % 100];
            number /= 100;
            number_buffer[length++] = (lookup_value & 15) + '0';
            number_buffer[length++] = (lookup_value >> 4) + '0';
        }

        if (number != 0 || length == 0)
            write_char(number + '0');

        for (int i = length - 1; i >= 0; i--)
            write_char(number_buffer[i]);

        if (after)
            write_char(after);
    }

    void init() {
        // Make sure _flush_output() is called at the end of the program.
        bool exit_success = atexit(_flush_output) == 0;
        assert(exit_success);

        for (int i = 0; i < 100; i++)
            lookup[i] = (i / 10 << 4) + i % 10;
    }
}

const int BITS = 18;

template<typename T>
struct xor_basis {
    // A list of basis values sorted in decreasing order, where each value has a unique highest bit.
    // We use a static array instead of a vector for better performance.
    T basis[BITS];
    int n = 0;

    T min_value(T start) const {
        for (int i = 0; i < n; i++)
            start = min(start, start ^ basis[i]);

        return start;
    }

    T max_value(T start = 0) const {
        for (int i = 0; i < n; i++)
            start = max(start, start ^ basis[i]);

        return start;
    }

    bool add(T x) {
        if (n == BITS)
            return false;

        x = min_value(x);

        if (x == 0)
            return false;

        basis[n++] = x;

        // Insertion sort.
        for (int k = n - 1; k > 0 && basis[k] > basis[k - 1]; k--)
            swap(basis[k], basis[k - 1]);

        return true;
    }

    void merge(const xor_basis<T> &other) {
        for (int i = 0; i < other.n && n < BITS; i++)
            add(other.basis[i]);
    }

    void merge(const xor_basis<T> &a, const xor_basis<T> &b) {
        *this = a;
        merge(b);
    }
};

int main() {
    IO::init();

    int N;
    IO::read_int(N);
    vector<int> S(N);

    for (int &s : S)
        IO::read_int(s);

    vector<int> original;

    for (int bits = BITS; bits >= 0; bits--) {
        xor_basis<int> basis;
        original.clear();

        for (int s : S)
            if (s < 1 << bits && basis.add(s))
                original.push_back(s);

        if ((int) original.size() == bits)
            break;
    }

    int bits = original.size();
    vector<int> permutation = {0};
    int number = 0;

    for (int i = 1; i < 1 << bits; i++) {
        number ^= original[__builtin_ctz(i)];
        permutation.push_back(number);
    }

    IO::write_int(bits, '\n');

    for (int i = 0; i < 1 << bits; i++)
        IO::write_int(permutation[i], i < (1 << bits) - 1 ? ' ' : '\n');
}


#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

const long double PI = 4 * atan((long double) 1);

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef complex<ld> cd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define f0r(i,a) for(int i=0;i<a;i++)
#define f1r(i,a,b) for(int i=a;i<b;i++)
#define trav(a, x) for (auto& a : x)
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rall(x) rbegin(x), rend(x)
#define resz resize
#define ins insert

template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
  cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}

template<class T> bool ckmin(T& a, const T& b) {
	return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }

namespace input {
	template<class T> void re(complex<T>& x);
	template<class T1, class T2> void re(pair<T1,T2>& p);
	template<class T> void re(vector<T>& a);
	template<class T, size_t SZ> void re(array<T,SZ>& a);

	template<class T> void re(T& x) { cin >> x; }
	void re(double& x) { string t; re(t); x = stod(t); }
	void re(ld& x) { string t; re(t); x = stold(t); }
	template<class T, class... Ts> void re(T& t, Ts&... ts) {
		re(t); re(ts...);
	}

	template<class T> void re(complex<T>& x) { T a,b; re(a,b); x = cd(a,b); }
	template<class T1, class T2> void re(pair<T1,T2>& p) { re(p.f,p.s); }
	template<class T> void re(vector<T>& a) { F0R(i,sz(a)) re(a[i]); }
	template<class T, size_t SZ> void re(array<T,SZ>& a) { F0R(i,SZ) re(a[i]); }
}

using namespace input;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }

	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);

	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) {
		pr(t); pr(ts...);
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) {
		pr("{",x.f,", ",x.s,"}");
	}
	template<class T> void pr(const T& x) {
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0;
		pr("}");
	}

	void ps() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void ps(const T& t, const Ts&... ts) {
		pr(t); if (sizeof...(ts)) pr(" "); ps(ts...);
	}

	void pc() { pr("]\n"); } // debug w/ commas
	template<class T, class... Ts> void pc(const T& t, const Ts&... ts) {
		pr(t); if (sizeof...(ts)) pr(", "); pc(ts...);
	}
	#define dbg(x...) pr("[",#x,"] = ["), pc(x);
}

using namespace output;

namespace io {
	void setIn(string s) { freopen(s.c_str(),"r",stdin); }
	void setOut(string s) { freopen(s.c_str(),"w",stdout); }
	void setIO(string s = "") {
		cin.sync_with_stdio(0); cin.tie(0); // fast I/O
		// cin.exceptions(cin.failbit); // ex. throws exception when you try to read letter into int
		if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
	}
}

using namespace io;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

const ll MOD = 1e9 + 7;

typedef decay<decltype(MOD)>::type T;
struct mi {
	T val;
	explicit operator T() const { return val; }
	mi() { val = 0; }
	mi(const ll& v) {
		val = (-MOD <= v && v <= MOD) ? v : v % MOD;
		if (val < 0) val += MOD;
	}
	// friend ostream& operator<<(ostream& os, const mi& a) {
		// return os << a.val; }
	friend void pr(const mi& a) { pr(a.val); }
	friend void re(mi& a) { ll x; re(x); a = mi(x); }

	friend bool operator==(const mi& a, const mi& b) {
		return a.val == b.val; }
	friend bool operator!=(const mi& a, const mi& b) {
		return !(a == b); }
	friend bool operator<(const mi& a, const mi& b) {
		return a.val < b.val; }

	mi operator-() const { return mi(-val); }
	mi& operator+=(const mi& m) {
		if ((val += m.val) >= MOD) val -= MOD;
		return *this; }
	mi& operator-=(const mi& m) {
		if ((val -= m.val) < 0) val += MOD;
		return *this; }
	mi& operator*=(const mi& m) {
		val = (ll)val*m.val%MOD; return *this; }
	friend mi pow(mi a, ll p) {
		mi ans = 1; assert(p >= 0);
		for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans;
	}
	friend mi inv(const mi& a) {
		assert(a != 0); return pow(a,MOD-2); }
	mi& operator/=(const mi& m) { return (*this) *= inv(m); }

	friend mi operator+(mi a, const mi& b) { return a += b; }
	friend mi operator-(mi a, const mi& b) { return a -= b; }
	friend mi operator*(mi a, const mi& b) { return a *= b; }
	friend mi operator/(mi a, const mi& b) { return a /= b; }
};

typedef pair<mi,mi> pmi;
typedef vector<mi> vmi;
typedef vector<pmi> vpmi;
const int MAX = 4e5+5;
int use[MAX];
vi adj[MAX];
vi basis;
vi s;
void add(int x, int top){
	if(x>= (1<<top)) return;
	if(sz(basis) == top) return;
	if(use[x] == 1) return;
	f0r(i, (1<<top)){
		if(use[i]){
			use[i^x] = 1;
		}
	}
	basis.eb(x);
	return;
}
vector<string> gray(int n) {
	vector<string> arr;
    if (n <= 0) return arr;
    arr.push_back("0");
    arr.push_back("1");
    int i, j;
    for (i = 2; i < (1<<n); i = i<<1) {
        for (j = i-1 ; j >= 0 ; j--) arr.push_back(arr[j]);
        for (j = 0 ; j < i ; j++) arr[j] = "0" + arr[j];
        for (j = i ; j < 2*i ; j++) arr[j] = "1" + arr[j];
    }
    return arr;
}
int main(){
	int n;
	re(n);
	int mx = ceil(log2(n))+1;
	f0r(i, n){
		int si;
		re(si);
		s.eb(si);
	}
	for(int i = mx+2; i>= 0; i--){
		basis.clear();
		f0r(j, MAX) use[j] = 0;
		use[0] = 1;
		f0r(j, n) add(s[j], i);
		if(sz(basis) == i){
			vector<string> codes = gray(i);
			ps(i);
			f0r(a, (1<<i)){
				int val = 0;
				f0r(b, i){
					if(codes[a][b] == '1') val ^= basis[b];
				}
				pr(val, " ");
			}
			ps();
			return 0;
		}
	}
	return 0;
}


#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

const long double PI = 4 * atan((long double) 1);

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef complex<ld> cd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define f0r(i,a) for(int i=0;i<a;i++)
#define f1r(i,a,b) for(int i=a;i<b;i++)
#define trav(a, x) for (auto& a : x)
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rall(x) rbegin(x), rend(x)
#define resz resize
#define ins insert

template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
  cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}

template<class T> bool ckmin(T& a, const T& b) {
	return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }

namespace input {
	template<class T> void re(complex<T>& x);
	template<class T1, class T2> void re(pair<T1,T2>& p);
	template<class T> void re(vector<T>& a);
	template<class T, size_t SZ> void re(array<T,SZ>& a);

	template<class T> void re(T& x) { cin >> x; }
	void re(double& x) { string t; re(t); x = stod(t); }
	void re(ld& x) { string t; re(t); x = stold(t); }
	template<class T, class... Ts> void re(T& t, Ts&... ts) {
		re(t); re(ts...);
	}

	template<class T> void re(complex<T>& x) { T a,b; re(a,b); x = cd(a,b); }
	template<class T1, class T2> void re(pair<T1,T2>& p) { re(p.f,p.s); }
	template<class T> void re(vector<T>& a) { F0R(i,sz(a)) re(a[i]); }
	template<class T, size_t SZ> void re(array<T,SZ>& a) { F0R(i,SZ) re(a[i]); }
}

using namespace input;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }

	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);

	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) {
		pr(t); pr(ts...);
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) {
		pr("{",x.f,", ",x.s,"}");
	}
	template<class T> void pr(const T& x) {
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0;
		pr("}");
	}

	void ps() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void ps(const T& t, const Ts&... ts) {
		pr(t); if (sizeof...(ts)) pr(" "); ps(ts...);
	}

	void pc() { pr("]\n"); } // debug w/ commas
	template<class T, class... Ts> void pc(const T& t, const Ts&... ts) {
		pr(t); if (sizeof...(ts)) pr(", "); pc(ts...);
	}
	#define dbg(x...) pr("[",#x,"] = ["), pc(x);
}

using namespace output;

namespace io {
	void setIn(string s) { freopen(s.c_str(),"r",stdin); }
	void setOut(string s) { freopen(s.c_str(),"w",stdout); }
	void setIO(string s = "") {
		cin.sync_with_stdio(0); cin.tie(0); // fast I/O
		// cin.exceptions(cin.failbit); // ex. throws exception when you try to read letter into int
		if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
	}
}

using namespace io;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

const ll MOD = 1e9 + 7;

typedef decay<decltype(MOD)>::type T;
struct mi {
	T val;
	explicit operator T() const { return val; }
	mi() { val = 0; }
	mi(const ll& v) {
		val = (-MOD <= v && v <= MOD) ? v : v % MOD;
		if (val < 0) val += MOD;
	}
	// friend ostream& operator<<(ostream& os, const mi& a) {
		// return os << a.val; }
	friend void pr(const mi& a) { pr(a.val); }
	friend void re(mi& a) { ll x; re(x); a = mi(x); }

	friend bool operator==(const mi& a, const mi& b) {
		return a.val == b.val; }
	friend bool operator!=(const mi& a, const mi& b) {
		return !(a == b); }
	friend bool operator<(const mi& a, const mi& b) {
		return a.val < b.val; }

	mi operator-() const { return mi(-val); }
	mi& operator+=(const mi& m) {
		if ((val += m.val) >= MOD) val -= MOD;
		return *this; }
	mi& operator-=(const mi& m) {
		if ((val -= m.val) < 0) val += MOD;
		return *this; }
	mi& operator*=(const mi& m) {
		val = (ll)val*m.val%MOD; return *this; }
	friend mi pow(mi a, ll p) {
		mi ans = 1; assert(p >= 0);
		for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans;
	}
	friend mi inv(const mi& a) {
		assert(a != 0); return pow(a,MOD-2); }
	mi& operator/=(const mi& m) { return (*this) *= inv(m); }

	friend mi operator+(mi a, const mi& b) { return a += b; }
	friend mi operator-(mi a, const mi& b) { return a -= b; }
	friend mi operator*(mi a, const mi& b) { return a *= b; }
	friend mi operator/(mi a, const mi& b) { return a /= b; }
};

typedef pair<mi,mi> pmi;
typedef vector<mi> vmi;
typedef vector<pmi> vpmi;
const int MAX = 4e5+5;
int use[MAX];
vi adj[MAX];
vi basis;
vi s;
void add(int x, int top){
	if(x>= (1<<top)) return;
	if(sz(basis) == top) return;
	if(use[x] == 1) return;
	f0r(i, (1<<top)){
		if(use[i]){
			use[i^x] = 1;
		}
	}
	basis.eb(x);
	return;
}
vector<string> gray(int n) {
	vector<string> arr;
    if (n <= 0) return arr;
    arr.push_back("0");
    arr.push_back("1");
    int i, j;
    for (i = 2; i < (1<<n); i = i<<1) {
        for (j = i-1 ; j >= 0 ; j--) arr.push_back(arr[j]);
        for (j = 0 ; j < i ; j++) arr[j] = "0" + arr[j];
        for (j = i ; j < 2*i ; j++) arr[j] = "1" + arr[j];
    }
    return arr;
}
int main(){
	int n;
	re(n);
	int mx = ceil(log2(n))+1;
	f0r(i, n){
		int si;
		re(si);
		s.eb(si);
	}
	for(int i = 20; i>= 0; i--){
		basis.clear();
		f0r(j, MAX) use[j] = 0;
		use[0] = 1;
		f0r(j, n) add(s[j], i);
		if(sz(basis) == i){
			vector<string> codes = gray(i);
			ps(i);
			f0r(a, (1<<i)){
				int val = 0;
				f0r(b, i){
					if(codes[a][b] == '1') val ^= basis[b];
				}
				pr(val, " ");
			}
			ps();
			return 0;
		}
	}
	return 0;
}


#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

const long double PI = 4 * atan((long double) 1);

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef complex<ld> cd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define f0r(i,a) for(int i=0;i<a;i++)
#define f1r(i,a,b) for(int i=a;i<b;i++)
#define trav(a, x) for (auto& a : x)
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rall(x) rbegin(x), rend(x)
#define resz resize
#define ins insert

template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
  cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}

template<class T> bool ckmin(T& a, const T& b) {
	return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }

namespace input {
	template<class T> void re(complex<T>& x);
	template<class T1, class T2> void re(pair<T1,T2>& p);
	template<class T> void re(vector<T>& a);
	template<class T, size_t SZ> void re(array<T,SZ>& a);

	template<class T> void re(T& x) { cin >> x; }
	void re(double& x) { string t; re(t); x = stod(t); }
	void re(ld& x) { string t; re(t); x = stold(t); }
	template<class T, class... Ts> void re(T& t, Ts&... ts) {
		re(t); re(ts...);
	}

	template<class T> void re(complex<T>& x) { T a,b; re(a,b); x = cd(a,b); }
	template<class T1, class T2> void re(pair<T1,T2>& p) { re(p.f,p.s); }
	template<class T> void re(vector<T>& a) { F0R(i,sz(a)) re(a[i]); }
	template<class T, size_t SZ> void re(array<T,SZ>& a) { F0R(i,SZ) re(a[i]); }
}

using namespace input;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }

	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);

	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) {
		pr(t); pr(ts...);
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) {
		pr("{",x.f,", ",x.s,"}");
	}
	template<class T> void pr(const T& x) {
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0;
		pr("}");
	}

	void ps() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void ps(const T& t, const Ts&... ts) {
		pr(t); if (sizeof...(ts)) pr(" "); ps(ts...);
	}

	void pc() { pr("]\n"); } // debug w/ commas
	template<class T, class... Ts> void pc(const T& t, const Ts&... ts) {
		pr(t); if (sizeof...(ts)) pr(", "); pc(ts...);
	}
	#define dbg(x...) pr("[",#x,"] = ["), pc(x);
}

using namespace output;

namespace io {
	void setIn(string s) { freopen(s.c_str(),"r",stdin); }
	void setOut(string s) { freopen(s.c_str(),"w",stdout); }
	void setIO(string s = "") {
		cin.sync_with_stdio(0); cin.tie(0); // fast I/O
		// cin.exceptions(cin.failbit); // ex. throws exception when you try to read letter into int
		if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
	}
}

using namespace io;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

const ll MOD = 1e9 + 7;

typedef decay<decltype(MOD)>::type T;
struct mi {
	T val;
	explicit operator T() const { return val; }
	mi() { val = 0; }
	mi(const ll& v) {
		val = (-MOD <= v && v <= MOD) ? v : v % MOD;
		if (val < 0) val += MOD;
	}
	// friend ostream& operator<<(ostream& os, const mi& a) {
		// return os << a.val; }
	friend void pr(const mi& a) { pr(a.val); }
	friend void re(mi& a) { ll x; re(x); a = mi(x); }

	friend bool operator==(const mi& a, const mi& b) {
		return a.val == b.val; }
	friend bool operator!=(const mi& a, const mi& b) {
		return !(a == b); }
	friend bool operator<(const mi& a, const mi& b) {
		return a.val < b.val; }

	mi operator-() const { return mi(-val); }
	mi& operator+=(const mi& m) {
		if ((val += m.val) >= MOD) val -= MOD;
		return *this; }
	mi& operator-=(const mi& m) {
		if ((val -= m.val) < 0) val += MOD;
		return *this; }
	mi& operator*=(const mi& m) {
		val = (ll)val*m.val%MOD; return *this; }
	friend mi pow(mi a, ll p) {
		mi ans = 1; assert(p >= 0);
		for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans;
	}
	friend mi inv(const mi& a) {
		assert(a != 0); return pow(a,MOD-2); }
	mi& operator/=(const mi& m) { return (*this) *= inv(m); }

	friend mi operator+(mi a, const mi& b) { return a += b; }
	friend mi operator-(mi a, const mi& b) { return a -= b; }
	friend mi operator*(mi a, const mi& b) { return a *= b; }
	friend mi operator/(mi a, const mi& b) { return a /= b; }
};

typedef pair<mi,mi> pmi;
typedef vector<mi> vmi;
typedef vector<pmi> vpmi;
const int MAX = 6e5+5;
int use[MAX];
vi adj[MAX];
vi basis;
vi s;
void add(int x, int top){
	if(x>= (1<<top)) return;
	if(sz(basis) == top) return;
	if(use[x] == 1) return;
	f0r(i, (1<<top)){
		if(use[i]){
			use[i^x] = 1;
		}
	}
	basis.eb(x);
	return;
}
vector<string> gray(int n) {
	vector<string> arr;
    if (n <= 0) return arr;
    arr.push_back("0");
    arr.push_back("1");
    int i, j;
    for (i = 2; i < (1<<n); i = i<<1) {
        for (j = i-1 ; j >= 0 ; j--) arr.push_back(arr[j]);
        for (j = 0 ; j < i ; j++) arr[j] = "0" + arr[j];
        for (j = i ; j < 2*i ; j++) arr[j] = "1" + arr[j];
    }
    return arr;
}
int main(){
	int n;
	re(n);
	int mx = ceil(log2(n))+1;
	f0r(i, n){
		int si;
		re(si);
		s.eb(si);
	}
	for(int i = 19; i>= 0; i--){
		basis.clear();
		f0r(j, MAX) use[j] = 0;
		use[0] = 1;
		f0r(j, n) add(s[j], i);
		if(sz(basis) == i){
			vector<string> codes = gray(i);
			ps(i);
			f0r(a, (1<<i)){
				int val = 0;
				f0r(b, i){
					if(codes[a][b] == '1') val ^= basis[b];
				}
				pr(val, " ");
			}
			ps();
			return 0;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define oo 1000000
#define mod 1000000007
const int N = 22;
int n , arr[(1 << N) + 5] , arr2[(1 << N) + 5] , nn , arr3[(1 << N) + 5];
int vis[(1 << 22)] , vi = 0;
void check(int cur){
	nn = 0;
	vi++;
	for(int i = 0 ;i < n;i++){
		if(arr[i] < (1 << cur)){
			if(vis[arr[i]] == vi) continue;
			arr2[nn++] = arr[i];
			vis[arr[i]] = vi;
			for(int j = 0 ;j < nn;j++){
				vis[(arr[i] ^ arr2[j])] = vi;
			}
		}
	}
	if((1 << nn) < (1 << cur)) return;
	vi++;
	arr3[0] = 0;
	vis[0] = vi;
	for(int i = 1 ;i < (1 << cur);i++){
		for(int j = 0 ;j < nn;j++){
			if(vis[(arr3[i - 1] ^ arr2[j])] == vi) continue;
			vis[(arr3[i - 1] ^ arr2[j])] = vi;
			arr3[i] = (arr3[i - 1] ^ arr2[j]);
			break;
		}
	}
	cout << cur << endl;
	for(int i = 0 ;i < (1 << cur);i++){
		if(i) putchar(' ');
		printf("%d",arr3[i]);
	}
	puts("");
	exit(0);

}

int main(){
	scanf("%d",&n);
	for(int i =0  ;i < n;i++){
		scanf("%d",&arr[i]);
	}
	for(int ans = 22;ans > 0;ans--){
		check(ans);
	}
	cout << "0 \n0\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define oo 1000000
#define mod 1000000007
const int N = 22;
int n , arr[(1 << N) + 5] , arr2[(1 << N) + 5] , nn , arr3[(1 << N) + 5];
int vis[(1 << 22)] , vi = 0;
void check(int cur){
	nn = 0;
	vi++;
	for(int i = 0 ;i < n;i++){
		if(arr[i] < (1 << cur)){
			if(vis[arr[i]] == vi) continue;
			arr2[nn++] = arr[i];
			vis[arr[i]] = vi;
			for(int j = 0 ;j < nn;j++){
				vis[(arr[i] ^ arr2[j])] = vi;
			}
		}
	}
	if((1 << nn) < (1 << cur)) return;
	vi++;
	arr3[0] = 0;
	vis[0] = vi;
	for(int i = 1 ;i < (1 << cur);i++){
		for(int j = 0 ;j < nn;j++){
			if(vis[(arr3[i - 1] ^ arr2[j])] == vi) continue;
			vis[(arr3[i - 1] ^ arr2[j])] = vi;
			arr3[i] = (arr3[i - 1] ^ arr2[j]);
			break;
		}
	}
	cout << cur << endl;
	for(int i = 0 ;i < (1 << cur);i++){
		if(i) putchar(' ');
		printf("%d",arr3[i]);
	}
	puts("");
	exit(0);

}

int main(){
	scanf("%d",&n);
	int mx = 0;
	for(int i =0  ;i < n;i++){
		scanf("%d",&arr[i]);
		for(int j = N;j>=0;j--){
			if(((arr[i] >> j) & 1) == 1)
				mx = max(mx,j + 1);
		}
	}
	for(int ans = mx;ans > 0;ans--){
		check(ans);
	}
	cout << "0 \n0\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define oo 1000000
#define mod 1000000007
const int N = 22;
int n , arr[(1 << N) + 5] , arr2[(1 << N) + 5] , nn , arr3[(1 << N) + 5];
int vis[(1 << 22)] , vi = 0;
void check(int cur){
	nn = 0;
	vi++;
	for(int i = 0 ;i < n;i++){
		if(arr[i] < (1 << cur)){
			if(vis[arr[i]] == vi) continue;
			arr2[nn++] = arr[i];
			vis[arr[i]] = vi;
			for(int j = 0 ;j < nn;j++){
				vis[(arr[i] ^ arr2[j])] = vi;
			}
		}
	}
	if((1 << nn) < (1 << cur)) return;
	vi++;
	arr3[0] = 0;
	vis[0] = vi;
	for(int i = 1 ;i < (1 << cur);i++){
		for(int j = 0 ;j < nn;j++){
			if(vis[(arr3[i - 1] ^ arr2[j])] == vi) continue;
			vis[(arr3[i - 1] ^ arr2[j])] = vi;
			arr3[i] = (arr3[i - 1] ^ arr2[j]);
			break;
		}
	}
	for(int i = 0 ;i < (1 << cur);i++){
		if(i) putchar(' ');
		printf("%d",arr3[i]);
	}
	puts("");
	exit(0);

}

int main(){
	scanf("%d",&n);
	for(int i =0  ;i < n;i++){
		scanf("%d",&arr[i]);
	}
	for(int ans = 22;ans > 0;ans--){
		check(ans);
	}
	cout << "0 \n0\n";
	return 0;
}


# include <iostream>
# include <math.h>
# include <fstream>
# include <vector>
# include <algorithm>
# include <string>
# include <set>
using namespace std;
//printf ("%.8lf\n", a);
// erase

/*
    ifstream fin;
    fin.open("input.txt");
    ofstream fout;
    fout.open("output.txt");
*/

# define all(a) a.begin(), a.end()
# define Sort(a) sort(all(a));
# define pause system("pause");
# define ll long long
# define VI vector <int>
# define vll vector <ll>
# define pb push_back
# define pob pop_back
# define Graph vector < vector <bool> >

int main()
{
    int n, m, k=0;
    cin>>n;

    long float z=0, t;

    string s;
    for(int i=0; i<2*n; ++i)
    {
        cin>>s;
        m=s.length();

        t=double( int( s[m-3] ) - int('0') )/10  +  double( int( s[m-2] ) - int('0') )/100 +double( int( s[m-1] ) - int('0') )/1000 ;
        if(t>0) {z+=t; ++k;}
    }

    double ans=3000;
    for(int i=0; i<=min(n,k); ++i) if(ans> abs( double(i)-z ) ) ans=abs( double(i)-z );

    printf ("%.3lf\n", ans);

}


# include <iostream>
# include <math.h>
# include <fstream>
# include <vector>
# include <algorithm>
# include <string>
# include <set>
using namespace std;
//printf ("%.8lf\n", a);
// erase

/*
    ifstream fin;
    fin.open("input.txt");
    ofstream fout;
    fout.open("output.txt");
*/

# define all(a) a.begin(), a.end()
# define Sort(a) sort(all(a));
# define pause system("pause");
# define ll long long
# define VI vector <int>
# define vll vector <ll>
# define pb push_back
# define pob pop_back
# define Graph vector < vector <bool> >

int main()
{
    int n, m, k=0;
    cin>>n;

    double z=0, t;

    string s;
    for(int i=0; i<2*n; ++i)
    {
        cin>>s;
        m=s.length();

        t=double( int( s[m-3] ) - int('0') )/10  +  double( int( s[m-2] ) - int('0') )/100 +double( int( s[m-1] ) - int('0') )/1000 ;
        if(t>0) {z+=t; ++k;}
    }

    double ans=3000;
    if(k<=n) for(int i=0; i<=k; ++i) {if(ans> abs( double(i)-z ) ) ans=abs( double(i)-z );}
    else for(int i=k-n; i<=n; ++i){ if(ans> abs( double(i)-z ) ) ans=abs( double(i)-z );  }

     printf ("%.3lf\n", ans);

}


# include <iostream>
# include <math.h>
# include <fstream>
# include <vector>
# include <algorithm>
# include <string>
using namespace std;
//printf ("%.8lf\n", a);
// erase

# define all(a) a.begin(), a.end()
# define Sort(a) sort(all(a));
# define pause system("pause");
# define ll long long
# define VI vector <int>
# define vll vector <ll>
# define pb push_back
# define pob pop_back
# define Graph vector < vector <bool> >

int mod=1000000007;

int modul(int x)
{
    if(x>=0) return x;

    return -x;
}

double modul(double x)
{
    if(x>=0) return x;

    return -x;
}

int main()
{
    int n,  t=0; ll k;
    long float sum=0, b, a;
    cin>>n;
    //vector <double> a(2*n);
    //vector <double> b(2*n);
    for(int i=0; i<2*n; ++i)
    {
        cin>>a;

        k= int(a*1000000000);
        k%=1000000000;

        if(k)
        {
        b= double(k)/1000000000;
        sum= sum+b;
        ++t;
        }

    }
    //cout<<sum<<endl;

    long float ans=1000000, ans1;

    if(n >= t)
    {
        for(int i=0; i<=t; ++i)
        {
            ans1 = modul(sum- double(i) );
            //cout<<ans1<<endl;

            if(ans>ans1) ans=ans1;
        }

    }
    else
    {
        for(int i=t-n; i<=n; ++i)
        {
            ans1 = modul(sum- double(i) );
            //cout<<ans1<<endl;

            if(ans>ans1) ans=ans1;
        }
    }

    //if(ans== 0.029) ans=0.028;

    printf ("%.3lf\n", ans);
    //pause;

}


# include <iostream>
# include <math.h>
# include <fstream>
# include <vector>
# include <algorithm>
# include <string>
# include <set>
using namespace std;
//printf ("%.8lf\n", a);
// erase

/*
    ifstream fin;
    fin.open("input.txt");
    ofstream fout;
    fout.open("output.txt");
*/

# define all(a) a.begin(), a.end()
# define Sort(a) sort(all(a));
# define pause system("pause");
# define ll long long
# define VI vector <int>
# define vll vector <ll>
# define pb push_back
# define pob pop_back
# define Graph vector < vector <bool> >

int main()
{
    int n, m, k=0;
    cin>>n;

    double z=0, t;

    string s;
    for(int i=0; i<2*n; ++i)
    {
        cin>>s;
        m=s.length();

        t=double( int( s[m-3] ) - int('0') )/10  +  double( int( s[m-2] ) - int('0') )/100 +double( int( s[m-1] ) - int('0') )/1000 ;
        if(t>0) {z+=t; ++k;}
    }

    double ans=3000;
    if(k<=n) for(int i=0; i<=k; ++i) if(ans> abs( double(i)-z ) ) ans=abs( double(i)-z );
    else for(int i=k-n; i<=n; ++i) if(ans> abs( double(i)-z ) ) ans=abs( double(i)-z );

    printf ("%.3lf\n", ans);

}


# include <iostream>
# include <math.h>
# include <fstream>
# include <vector>
# include <algorithm>
# include <string>
using namespace std;
//printf ("%.8lf\n", a);
// erase

# define all(a) a.begin(), a.end()
# define Sort(a) sort(all(a));
# define pause system("pause");
# define ll long long
# define VI vector <int>
# define vll vector <ll>
# define pb push_back
# define pob pop_back
# define Graph vector < vector <bool> >

int mod=1000000007;

int modul(int x)
{
    if(x>=0) return x;

    return -x;
}

double modul(double x)
{
    if(x>=0) return x;

    return -x;
}

int main()
{
    int n, k, t=0;
    long float sum=0, b, a;
    cin>>n;
    //vector <double> a(2*n);
    //vector <double> b(2*n);
    for(int i=0; i<2*n; ++i)
    {
        cin>>a;

        k= int(a*10000);
        k%=10000;

        if(k)
        {
        b= double(k)/10000;
        sum= sum+b;
        ++t;
        }

    }
    //cout<<sum<<endl;

    long float ans=1000000, ans1;

    if(n >= t)
    {
        for(int i=0; i<=t; ++i)
        {
            ans1 = modul(sum- double(i) );
            //cout<<ans1<<endl;

            if(ans>ans1) ans=ans1;
        }

    }
    else
    {
        for(int i=t-n; i<=n; ++i)
        {
            ans1 = modul(sum- double(i) );
            //cout<<ans1<<endl;

            if(ans>ans1) ans=ans1;
        }
    }

    //if(ans== 0.029) ans=0.028;

    printf ("%.3lf\n", ans);
    //pause;

}


#include<iostream>
#include<cmath>
using namespace std;
/*
	we want abs( 1000*n - ( sum - x ) -x ) to be as minimum as possible
	but it's just a constant - -!
	but notice that: when  3.000   it can't be 4 or 2, it only changed to be 3
*/

int main()
{
	int i,n,sum=0,y,cnt,k;
	double a;
	cin>>n;
	cnt=0;
	for(i=0;i<(n<<1);i++)
	{
		scanf("%lf",&a);
		y=(int)(a*1000)%1000;
		if(y!=0)
			sum+=y;
		else
			cnt++;
	}
	k=cnt;
	if(cnt%2)
		cnt--;
	// notice : if cnt%2, there will be a x.000  , it just be x, not x+1 or x-1
	n-=cnt/2;
	if(!(k%2))
		printf("%.3lf\n",(double)abs(1000*n-sum)/1000);
	else
	{
		int z;
		y=abs(1000*n-sum);
		z=abs(abs(1000*n-sum)-1000);
		if(y<z)
			z=y;
		printf("%.3lf\n",(double)z/1000);
	}
}


#include<iostream>
#include<cmath>
using namespace std;
/*
	we want abs( 1000*n - ( sum - x ) -x ) to be as minimum as possible
	but it's just a constant - -!
	but notice that: when  3.000   it can't be 4 or 2, it only changed to be 3
*/

int main()
{
	int i,n,sum=0,y,cnt;
	double a;
	cin>>n;
	cnt=0;
	for(i=0;i<(n<<1);i++)
	{
		scanf("%lf",&a);
		y=(int)(a*1000)%1000;
		if(y!=0)
			sum+=y;
		else
			cnt++;
	}
	if(cnt%2)
		cnt--;
	// notice : if cnt%2, there will be a x.000  , it just be x, not x+1 or x-1
	n-=cnt/2;
	if(!(n%2))
		printf("%.3lf\n",(double)abs(1000*n-sum)/1000);
	else
	{
		int z;
		y=abs(1000*n-sum);
		z=abs(abs(1000*n-sum)-1000);
		if(y<z)
			z=y;
		printf("%.3lf\n",(double)z/1000);
	}
}


#include<iostream>
#include<cmath>
using namespace std;
/*
	we want abs( 1000*n - ( sum - x ) -x ) to be as minimum as possible
	but it's just a constant - -!
	but notice that: when  3.000   it can't be 4 or 2, it only changed to be 3
*/

int main()
{
	int i,n,sum=0,y,cnt;
	double a;
	cin>>n;
	cnt=0;
	for(i=0;i<(n<<1);i++)
	{
		scanf("%lf",&a);
		y=(int)(a*1000)%1000;
		if(y!=0)
			sum+=y;
		else
			cnt++;
	}
	if(cnt%2)
		cnt--;
	n-=cnt/2;
	printf("%.3lf\n",(double)abs(1000*n-sum)/1000);
}


#include<iostream>
#include<cmath>
using namespace std;
const int M = (int)(1e9+5);
/*
	no matter cnt0 is odd or even, 1000*m-(sum-x)-x is constant,0<=m<=?
*/

int main()
{
	int n,m,i,j,k,sum,x,y;
	int cnt0,st,asr;//start
	sum=0;
	cin>>n;
	cnt0=0;
	for(i=0;i<(n<<1);i++)
	{
		scanf("%d.%d",&y,&x);
		sum+=x;
		if(x==0)
			cnt0++;
	}
	st=0;
	m=(n<<1)-cnt0;
	if(cnt0<n)
		st=n-cnt0;
	asr=M;
	for(i=st;i<=n&&i<=m;i++)
	{
		x=abs(1000*i-sum);
		//cout<<x<<endl;
		if(x<asr)
			asr=x;
	}
//	cout<<asr<<endl;
	printf("%.3lf\n",(double)asr/1000);
}


#include <iostream>
using namespace std;

int main()
{
    int n; cin >> n;

    double a;
    int f = 0;
    double sum = -n;

    for ( int i=1; i<=2*n; i++ ) {
        cin >> a;

        int ca = a;
        if ( ca - a == 0 ) f++;
        sum+= a - ca;
    }
    double ans = 1000000;

    for ( int i=0; i<=f; i++ )
        ans = min( abs(sum + i), ans );

    printf("%6.3f",ans);

    return 0;
}


#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int n; cin >> n;

    double *a = new double[2*n+2];
    bool *pa = new bool[2*n+2];

    for ( int i=1; i<=2*n; i++ ) {
        cin >> a[i];
        pa[i] = false;
    }

    double r = 0;
    for ( int i=2*n; i>=1; i-- ) {
        if ( pa[i] == true ) continue;

        pa[i] = true;

        int indj;
        double s = 10001;
        for ( int j=1; j<=2*n; j++ ) {
            if ( pa[j] == true ) continue;

            double s1 = min( abs( r + a[i] + a[j] - ceil( a[i] ) - floor( a[j] ) ), abs( r + a[i] + a[j] - ceil( a[j] ) - floor( a[i] ) ));
            if ( abs(s) > abs(s1)  ) {
                if ( abs( r + a[i] + a[j] - ceil( a[i] ) - floor( a[j] ) ) < abs( r + a[i] + a[j] - ceil( a[j] ) - floor( a[i] ) ) )
                   s = r + a[i] + a[j] - ceil( a[i] ) - floor( a[j] );
                else
                   s = r + a[i] + a[j] - ceil( a[j] ) - floor( a[i] );
            indj = j;
            }
        }

        pa[indj] = true;
        r = s;
    }

    printf("%6.3f",abs(r));
    return 0;
}


#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int n; cin >> n;

    double *a = new double[2*n+2];
    bool *pa = new bool[2*n+2];

    for ( int i=1; i<=2*n; i++ ) {
        cin >> a[i];
        pa[i] = false;
    }

    double r = 0;
    for ( int i=1; i<=2*n; i++ ) {
        if ( pa[i] == true ) continue;

        pa[i] = true;

        int indj;
        double s = 10001;
        for ( int j=i+1; j<=2*n; j++ ) {
            if ( pa[j] == true ) continue;

            double s1 = min( abs( r + a[i] + a[j] - ceil( a[i] ) - floor( a[j] ) ), abs( r + a[i] + a[j] - ceil( a[j] ) - floor( a[i] ) ));
            if ( abs(s) > abs(s1)  ) {
                if ( abs( r + a[i] + a[j] - ceil( a[i] ) - floor( a[j] ) ) < abs( r + a[i] + a[j] - ceil( a[j] ) - floor( a[i] ) ) )
                   s = r + a[i] + a[j] - ceil( a[i] ) - floor( a[j] );
                else
                   s =  r + a[i] + a[j] - ceil( a[j] ) - floor( a[i] );
            indj = j;
            }
        }

        pa[indj] = true;
        r = s;
    }

    cout << r << endl;
    return 0;
}


#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int n; cin >> n;

    double *a = new double[2*n+2];
    bool *pa = new bool[2*n+2];

    for ( int i=1; i<=2*n; i++ ) {
        cin >> a[i];
        pa[i] = false;
    }

    double r = 0;
    for ( int i=1; i<=2*n; i++ ) {
        if ( pa[i] == true ) continue;

        pa[i] = true;

        int indj;
        double s = 10001;
        for ( int j=i+1; j<=2*n; j++ ) {
            if ( pa[j] == true ) continue;

            double s1 = min( abs( r + a[i] + a[j] - ceil( a[i] ) - floor( a[j] ) ), abs( r + a[i] + a[j] - ceil( a[j] ) - floor( a[i] ) ));
            if ( abs(s) > abs(s1)  ) {
                if ( abs( r + a[i] + a[j] - ceil( a[i] ) - floor( a[j] ) ) < abs( r + a[i] + a[j] - ceil( a[j] ) - floor( a[i] ) ) )
                   s = r + a[i] + a[j] - ceil( a[i] ) - floor( a[j] );
                else
                   s =  r + a[i] + a[j] - ceil( a[j] ) - floor( a[i] );
            indj = j;
            }
        }

        pa[indj] = true;
        r = s;
    }

    printf("%6.3f", r);

    return 0;
}


#include <iostream>
using namespace std;

int main()
{
    int n; cin >> n;

    double a;
    int f;
    double sum = -n;

    for ( int i=1; i<=2*n; i++ ) {
        cin >> a;

        int ca = a;
        if ( ca - a == 0 ) f++;
        sum+= a - ca;
    }
    double ans = 1000000;

    for ( int i=0; i<=f; i++ )
        ans = min( abs(sum + i), ans );

    printf("%6.3f",ans);
    return 0;
}


#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int n; cin >> n;

    double *a = new double[2*n+2];
    bool *pa = new bool[2*n+2];

    for ( int i=1; i<=2*n; i++ ) {
        cin >> a[i];
        pa[i] = false;
    }

    double r = 0;
    for ( int i=1; i<=2*n; i++ ) {
        if ( pa[i] == true ) continue;

        pa[i] = true;

        int indj;
        double s = 10001;
        for ( int j=i+1; j<=2*n; j++ ) {
            if ( pa[j] == true ) continue;

            double s1 = min( abs( r + a[i] + a[j] - ceil( a[i] ) - floor( a[j] ) ), abs( r + a[i] + a[j] - ceil( a[j] ) - floor( a[i] ) ));
            if ( abs(s) > abs(s1)  ) {
                if ( abs( r + a[i] + a[j] - ceil( a[i] ) - floor( a[j] ) ) < abs( r + a[i] + a[j] - ceil( a[j] ) - floor( a[i] ) ) )
                   s = r + a[i] + a[j] - ceil( a[i] ) - floor( a[j] );
                else
                   s =  r + a[i] + a[j] - ceil( a[j] ) - floor( a[i] );
            indj = j;
            }
        }

        pa[indj] = true;
        r = s;
    }

    printf("%6.3f", abs(r));

    return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:200000000")

#include<stdio.h>
#include<iostream>
#include<ctime>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>
#include<queue>
#include<set>
#include<map>

using namespace std;

#define forn(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define ford(i, n) for (int i = n - 1; i >= 0; i--)
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define sqr(x) (x) * (x)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

typedef long long ll;

const int MAXN = 4001;
const int INF = 0x3f3f3f3f;
const ll INF_64 = (1LL << 62);

double down(double a)
{
	int res = (int)a;
	return double(res);
}

double up(double a)
{
	int res = (int)a;
	if ((double)res == a)
		return (double)res;
	else
		return (double)(res + 1);
}

int n;
double a[MAXN], dp[2][MAXN][MAXN];

double MIN(double a, double b)
{
	if (abs(a) < abs(b))
		return a;
	else
		return b;
}

int main()
{
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);

	cin >> n;
	n *= 2;
	for1(i, n)
		cin >> a[i];
	forn(i, MAXN)
		forn(j, MAXN)
			dp[0][i][j] = (double)INF;
	forn(i, MAXN)
		forn(j, MAXN)
			dp[1][i][j] = -(double)INF;
	dp[0][0][0] = 0LL;
	dp[1][0][0] = 0LL;
	int m = n / 2;
	for (int i = 0; i < n; i++)
		for (int j = 0; j <= m; j++)
			for (int k = 0; k < 2; k++)
			{
				if (dp[k][i][j] == INF)
					continue;
				if (j < m)
				{
					double nxt = dp[k][i][j] - (a[i + 1] - down(a[i + 1]));
					if (nxt >= 0)
						dp[0][i + 1][j + 1] = min(nxt, dp[0][i + 1][j + 1]);
					else
						dp[1][i + 1][j + 1] = max(nxt, dp[1][i + 1][j + 1]);
				}
				if ((i - j) < m)
				{
					double nxt = dp[k][i][j] + (up(a[i + 1]) - a[i + 1]);
					if (nxt >= 0)
						dp[0][i + 1][j] = min(nxt, dp[0][i + 1][j]);
					else
						dp[1][i + 1][j] = max(nxt, dp[1][i + 1][j]);
				}
			}
	printf("%.03f", abs(MIN(dp[0][n][m], dp[1][n][m])));
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;

double a[4005];

int main(){
	int n;
	scanf("%d",&n);
	int i;
	int cnt=0;
	double sum=0;
	for(i=1;i<=2*n;i++){
		double b;
		scanf("%lf",&b);
		if(fabs(b-int(b))>1e-10){a[++cnt]=fabs(b-int(b));
		sum+=a[cnt];}
	}
	int num=2*n-cnt;
	int l,r;
	double ans=0;
	if(num<n){
		l=(2*n-num*2)/2;
		r=l+num;
	}
	else{
		l=0;
		r=2*n-num;
	}
	if((double)l>sum){
		ans=l-sum;
	}
	else if((double)r<sum){
		ans=sum-r;
	}
	else{
		sum-=(int)sum;
		ans=min(sum,1-sum);
	}
	printf("%.3lf\n",fabs(ans));
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;

double a[4005];

int main(){
	int n;
	scanf("%d",&n);
	int i;
	int cnt=0;
	for(i=1;i<=2*n;i++){
		double b;
		scanf("%lf",&b);
		if(fabs(b-int(b))>1e-10)a[++cnt]=fabs(b-int(b));
	}
	sort(a+1,a+cnt+1);
	double ans=0;
	int pos1=1,pos2=cnt;
	while(pos1<pos2){
		ans+=(a[pos1]-1+a[pos2]);
		pos1++;
		pos2--;
	}
	if(pos1==pos2){
		ans+=min(a[pos1],1-a[pos1]);
	}
	printf("%.3lf\n",fabs(ans));
	return 0;
}


#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <map>
#define int64 long long
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define repd(i,a,b) for (int i = a; i >= b; i--)
#define mp make_pair
const int nt = 1000010;
using namespace std;

double a[300000], d, s, t, s1;
int n, k, p;

int main()
{
    cin >> n;
    rep(i,1,2*n) cin >> a[i];
    d = 100000000.0;
    s = 0;
    rep(i,1,2*n) s += double(int(a[i]));
    s1 = 0;
    rep(i,1,2*n) s1 += a[i];
    k = 0;
    rep(i,1,2*n)
        if (double(int(a[i])) == a[i]) k++;
    p = 2 * n - k;
    rep(i,0,k)
    {
        if (i > p) break;
        if (k % 2 == 0)
        {
            if (i % 2 != 0) continue;
        }
        else
        {
            if (i % 2 == 0) continue;
        }
        rep(j,0,i)
        {
            t = s + double((p - i) / 2) + double(j);
            if (abs(t - s1) < d) d = abs(t - s1);
        }
    }
    printf("%.3lf\n",d);

    return 0;
}


#include <list>
#include <deque>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <memory>
#include <hash_map>
#include <hash_set>
#include <cmath>
#include <string>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <utility>
#include <ctime>
#include <bitset>
#include <iterator>
#include <numeric>

using namespace std;

#define FILE_READER freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define FAST_READER ios::sync_with_stdio(false); cin.tie(NULL);

int main() {

  //FILE_READER
  //FAST_READER

    int n;
    cin >> n;
    double sum=0.0;
    int one=0, zero;
    for (int i = 0; i < n + n; ++i) {
        double d;
        cin >> d;
        sum += ceil(d)-d;
        if (int(d*1000.0) % 1000 != 0) ++one;
    }
    zero = n + n - one;

    double ans = 1e9;
    for (int i = 0; i <= n; ++i) {
        if (i > one || n-i > zero)continue;
        ans = min(ans, abs(sum-i));
    }
    cout << setprecision(3) << fixed << ans;
    return 0;
}


#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <map>
#include <ctime>
#include <cstring>
#include <string>
#include <cstdio>
#include <cstring>

using namespace std;

#define ll long long
#define FOR(i,a,b) for(int i = a; i < b; ++i)
#define INF ((1LL) << 62)
#define y1 Y1
#define count newtemp
double ans,res=333333333;
int rt;
int n;
double x;
int main()
{
     ios::sync_with_stdio(false);
     cin>>n;
     FOR(i,0,n+n) {
      cin>>x;
      double q=x-(int)x;
      if (q!=0) {
         ans+=q;
         rt++;
      }
     }
     FOR(i,0,n+1)
         if (rt<i) break;
         else if (i+n+n-rt>=n) res=min(res,abs(ans-i));
     cout.precision(3);
     cout<<fixed<<res<<endl;
}


#define _CRT_SECURE_NO_WARNINGS

#pragma comment (linker, "/STACK:1000000000")

#include <iostream>
#include <ctime>
#include <string>
#include <vector>
#include <set>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <memory>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <complex>
#include <hash_map>
#include <hash_set>

using namespace std;

#define pb push_back
#define pob pop_back
#define itr iterator
#define rs resize
#define as assign
#define fs first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define mp make_pair
#define sz(a) (int)a.size()
#define FOR(i, n) for (int i = 0; i < n; ++i)
#define FOD(i, n) for (int i = n - 1; i >= 0; --i)

typedef long long ll;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <ll> vl;
typedef vector <vl> vvl;
typedef vector <bool> vb;
typedef vector <vb> vvb;
typedef vector <string> vs;
typedef vector <vs> vvs;
typedef vector <char> vc;
typedef vector <vc> vvc;
typedef vector <vvc> vvvc;
typedef vector <vvi> vvvi;
typedef vector <vvvi> vvvvi;
typedef vector <vvl> vvvl;
typedef vector <vvvl> vvvvl;
typedef vector <vvb> vvvb;
typedef double db;
typedef long double ldb;
typedef vector <db> vdb;
typedef vector <vdb> vvdb;
typedef vector <vvdb> vvvdb;
typedef vector <ldb> vldb;
typedef pair <int, int> ii;
typedef pair <int, char> ic;
typedef pair <ll, ll> lll;
typedef pair <int, ll> il;
typedef pair <ll, int> li;
typedef vector <ii> vii;
typedef vector <ic> vic;
typedef vector <vic> vvic;
typedef vector <vii> vvii;
typedef vector <lll> vll;
typedef vector <vll> vvll;
typedef pair <ll, int> li;
typedef pair <ll, ll> lll;
typedef pair <int, ll> il;
typedef set <int> si;
typedef set <ll> sl;
typedef set <li> sli;
typedef set <il> sil;
typedef set <lll> sll;
typedef set <ii> sii;
typedef set <pair <int, bool> > sib;
typedef vector <si> vsi;
typedef vector <sii> vsii;
typedef map <int, int> mii;
typedef map <string, int> msi;
typedef map <string, char> msc;
typedef map <char, int> mci;
typedef queue <int> qi;
typedef deque <int> di;
typedef stack <int> sti;

const int inf = (int)1e9 + 7;
const ldb eps = 1e-18;
const int M = 46;
const int N = 1001;

//int dp[M][N][N];

int main()
{
    int n;
    scanf("%d", &n);
    vl b;
    vl c;
    int t = 0;
    for (int i = 0; i < 2 * n; ++i)
    {
        db f;
        scanf("%lf", &f);
        ll d = ll(f * 1000);
        if (d > (d / 1000) * 1000 + 500)
            c.pb(d);
        if (d < (d / 1000) * 1000 + 500)
            b.pb(d);
        if (d == (d / 1000) * 1000 + 500)
        {
            if (t % 2 == 0)
                b.pb(d);
            else
                c.pb(d);
            t++;
        }
    }
    for (int i = 0; i < sz(b); ++i)
        for (int j = i + 1; j < sz(b); ++j)
            if (b[i] - (b[i] / 1000 + (b[i] % 1000 == 0)) * 1000 < b[j] - (b[j] / 1000) * 1000)
                swap(b[i], b[j]);
    for (int i = 0; i < sz(c); ++i)
        for (int j = i + 1; j < sz(c); ++j)
            if ((c[i] / 1000 + 1) * 1000 - c[i] < (c[j] / 1000 + 1) * 1000 - c[j])
                swap(c[i], c[j]);
    ll s = 0;
    if (sz(b) > sz(c))
    {
        for (int i = 0; i < sz(c); ++i)
        {
            s -= (c[i] / 1000 + 1) * 1000 - c[i];
            s += b[i] - (b[i] / 1000) * 1000;
        }
        for (int i = sz(c); i < n; ++i)
        {
            s += b[i] - (b[i] / 1000) * 1000;
            s -= (b[sz(b) - i + sz(c) - 1] % 1000 == 0 ? 0 : (b[sz(b) - i + sz(c) - 1] / 1000 + 1) * 1000 - b[sz(b) - i + sz(c) - 1]);
        }
    }
    else
    {
        for (int i = 0; i < sz(b); ++i)
        {
            s += b[i] - (b[i] / 1000) * 1000;
            s -= (c[i] / 1000 + 1) * 1000 - c[i];
        }
        for (int i = sz(b); i < n; ++i)
        {
            s -= (c[i] / 1000 + 1) * 1000 - c[i];
            s += c[sz(c) - i + sz(b) - 1] - (c[sz(c) - i + sz(b) - 1] / 1000) * 1000;
        }
    }
    printf("%.3lf", abs(db(s) / 1000));

    return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#pragma comment (linker, "/STACK:1000000000")

#include <iostream>
#include <ctime>
#include <string>
#include <vector>
#include <set>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <memory>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <complex>
#include <hash_map>
#include <hash_set>

using namespace std;

#define pb push_back
#define pob pop_back
#define itr iterator
#define rs resize
#define as assign
#define fs first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define mp make_pair
#define sz(a) (int)a.size()
#define FOR(i, n) for (int i = 0; i < n; ++i)
#define FOD(i, n) for (int i = n - 1; i >= 0; --i)

typedef long long ll;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <ll> vl;
typedef vector <vl> vvl;
typedef vector <bool> vb;
typedef vector <vb> vvb;
typedef vector <string> vs;
typedef vector <vs> vvs;
typedef vector <char> vc;
typedef vector <vc> vvc;
typedef vector <vvc> vvvc;
typedef vector <vvi> vvvi;
typedef vector <vvvi> vvvvi;
typedef vector <vvl> vvvl;
typedef vector <vvvl> vvvvl;
typedef vector <vvb> vvvb;
typedef double db;
typedef long double ldb;
typedef vector <db> vdb;
typedef vector <vdb> vvdb;
typedef vector <vvdb> vvvdb;
typedef vector <ldb> vldb;
typedef pair <int, int> ii;
typedef pair <int, char> ic;
typedef pair <ll, ll> lll;
typedef pair <int, ll> il;
typedef pair <ll, int> li;
typedef vector <ii> vii;
typedef vector <ic> vic;
typedef vector <vic> vvic;
typedef vector <vii> vvii;
typedef vector <lll> vll;
typedef vector <vll> vvll;
typedef pair <ll, int> li;
typedef pair <ll, ll> lll;
typedef pair <int, ll> il;
typedef set <int> si;
typedef set <ll> sl;
typedef set <li> sli;
typedef set <il> sil;
typedef set <lll> sll;
typedef set <ii> sii;
typedef set <pair <int, bool> > sib;
typedef vector <si> vsi;
typedef vector <sii> vsii;
typedef map <int, int> mii;
typedef map <string, int> msi;
typedef map <string, char> msc;
typedef map <char, int> mci;
typedef queue <int> qi;
typedef deque <int> di;
typedef stack <int> sti;

const int inf = (int)1e9 + 7;
const ldb eps = 1e-18;
const int M = 46;
const int N = 1001;

int main()
{
    int n;
    scanf("%d", &n);
    vdb a(2 * n);
    int s = 0;
    db t = 0;
    for (int i = 0; i < 2 * n; ++i)
    {
        scanf("%lf", &a[i]);
        if (ll(1000 * a[i]) == 1000 * (ll)a[i])
            s++;
        a[i] -= floor(a[i]);
        t += a[i];
    }
    db ans = 1e9;
    for (int i = max(0, n - s); i <= min(n, 2 * n - s); ++i)
        ans = min(ans, abs(t - i));
    printf("%.3lf", ans);
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#pragma comment (linker, "/STACK:1000000000")

#include <iostream>
#include <ctime>
#include <string>
#include <vector>
#include <set>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <memory>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <complex>
#include <hash_map>
#include <hash_set>

using namespace std;

#define pb push_back
#define pob pop_back
#define itr iterator
#define rs resize
#define as assign
#define fs first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define mp make_pair
#define sz(a) (int)a.size()
#define FOR(i, n) for (int i = 0; i < n; ++i)
#define FOD(i, n) for (int i = n - 1; i >= 0; --i)

typedef long long ll;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <ll> vl;
typedef vector <vl> vvl;
typedef vector <bool> vb;
typedef vector <vb> vvb;
typedef vector <string> vs;
typedef vector <vs> vvs;
typedef vector <char> vc;
typedef vector <vc> vvc;
typedef vector <vvc> vvvc;
typedef vector <vvi> vvvi;
typedef vector <vvvi> vvvvi;
typedef vector <vvl> vvvl;
typedef vector <vvvl> vvvvl;
typedef vector <vvb> vvvb;
typedef double db;
typedef long double ldb;
typedef vector <db> vdb;
typedef vector <vdb> vvdb;
typedef vector <vvdb> vvvdb;
typedef vector <ldb> vldb;
typedef pair <int, int> ii;
typedef pair <int, char> ic;
typedef pair <ll, ll> lll;
typedef pair <int, ll> il;
typedef pair <ll, int> li;
typedef vector <ii> vii;
typedef vector <ic> vic;
typedef vector <vic> vvic;
typedef vector <vii> vvii;
typedef vector <lll> vll;
typedef vector <vll> vvll;
typedef pair <ll, int> li;
typedef pair <ll, ll> lll;
typedef pair <int, ll> il;
typedef set <int> si;
typedef set <ll> sl;
typedef set <li> sli;
typedef set <il> sil;
typedef set <lll> sll;
typedef set <ii> sii;
typedef set <pair <int, bool> > sib;
typedef vector <si> vsi;
typedef vector <sii> vsii;
typedef map <int, int> mii;
typedef map <string, int> msi;
typedef map <string, char> msc;
typedef map <char, int> mci;
typedef queue <int> qi;
typedef deque <int> di;
typedef stack <int> sti;

const int inf = (int)1e9 + 7;
const ldb eps = 1e-18;
const int M = 46;
const int N = 1001;

//int dp[M][N][N];

bool ls1(ll a, ll b)
{
    return a - (a / 1000) * 1000 + 1000 * (a % 1000 == 0) < b - (b / 1000) * 1000;
}

bool ls2(ll a, ll b)
{
    return a - (a / 1000 + 1) * 1000 < b - (b / 1000 + 1) * 1000;
}

int main()
{
    int n;
    scanf("%d", &n);
    vl b;
    vl c;
    for (int i = 0; i < 2 * n; ++i)
    {
        db f;
        scanf("%lf", &f);
        ll d = ll(f * 1000);
        if (d > (d / 1000) * 1000 + 500)
            c.pb(d);
        else
            b.pb(d);
    }
    sort(c.begin(), c.end(), ls2);
    sort(b.begin(), b.end(), ls1);
    for (int i = 0; i < sz(b); ++i)
        for (int j = i + 1; j < sz(b); ++j)
            if (b[i] - (b[i] / 1000 + (b[i] % 1000 == 0)) * 1000 < b[j] - (b[j] / 1000) * 1000)
                swap(b[i], b[j]);
    ll s = 0;
    if (sz(b) > sz(c))
    {
        for (int i = 0; i < sz(c); ++i)
        {
            s -= (c[i] / 1000 + 1) * 1000 - c[i];
            s += b[i] - (b[i] / 1000) * 1000;
        }
        for (int i = sz(c); i < (sz(b) + sz(c)) / 2; ++i)
        {
            s += b[i] - (b[i] / 1000) * 1000;
            s -= (b[sz(b) - i + sz(c) - 1] % 1000 == 0 ? 0 : (b[sz(b) - i + sz(c) - 1] / 1000 + 1) * 1000 - b[sz(b) - i + sz(c) - 1]);
        }
    }
    else
    {
        for (int i = 0; i < sz(b); ++i)
        {
            s += b[i] - (b[i] / 1000) * 1000;
            s -= (c[i] / 1000 + 1) * 1000 - c[i];
        }
        for (int i = sz(b); i < (sz(b) + sz(c)) / 2; ++i)
        {
            s -= (c[i] / 1000 + 1) * 1000 - c[i];
            s += c[sz(c) - i + sz(b) - 1] - (c[sz(c) - i + sz(b) - 1] / 1000) * 1000;
        }
    }
    printf("%.3lf", abs(db(s) / 1000));

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int sum;
int k;
int n;

int myabs(int a) {return a<0?-a:a;}

void output(int a)
{
	printf("%d.%03d\n",a/1000,a%1000);
}

void solve()
{
	int a = sum + 1000 * max(0,k-n), b = sum + 1000 * min(n,k);
	if(b<=0) output(myabs(b));
	else if(a>=0) output(myabs(a));
	else
	{
		b = b%1000;
		output(min(myabs(b),myabs(1000-b)));
	}
}

int main()
{
	cin>>n;
	sum = 0; k  = 0;
	for(int i=0;i<2*n;i++)
	{
		double a;
		cin>>a;
		int t = int(a*1000+0.1);
		sum -= t%1000;
		if(t%1000) k++;
	}
	solve();
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int sum;
int k;
int n;

int abs(int a) {return a<0?-a:a;}

void solve()
{
	int ans = 100000000;
	for(int i = max(0,k-n);i<=min(n,k);i++)
		ans = min(ans,abs(sum+i*1000));
	printf("%d.%03d\n",ans/1000,ans%1000);
}

int main()
{
	cin>>n;
	sum = 0; k  = 0;
	for(int i=0;i<2*n;i++)
	{
		double a;
		cin>>a;
		int t = int(a*1000+0.1);
		sum -= t%1000;
		if(t%1000) k++;
	}
	solve();
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int sum;
int k;
int n;

int myabs(int a) {return a<0?-a:a;}

void output(int a)
{
	printf("%d.%03d\n",a/1000,a%1000);
}

void solve()
{
	int a = sum + 1000 * max(0,k-n), b = sum + 1000 * min(n,k);
	if(b<=0) output(myabs(b));
	else if(a>=0) output(myabs(a));
	else
	{
		a = a%1000;
		output(min(myabs(a),myabs(1000-a)));
	}
}

int main()
{
	cin>>n;
	sum = 0; k  = 0;
	for(int i=0;i<2*n;i++)
	{
		double a;
		cin>>a;
		int t = int(a*1000+0.1);
		sum -= t%1000;
		if(t%1000) k++;
	}
	solve();
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int sum;
int k;
int n;

int myabs(int a) {return a<0?-a:a;}

void solve()
{
	int ans = 100000000;
	for(int i = max(0,k-n);i<=min(n,k);i++)
		ans = min(ans,myabs(sum+i*1000));
	printf("%d.%03d\n",ans/1000,ans%1000);
}

int main()
{
	cin>>n;
	sum = 0; k  = 0;
	for(int i=0;i<2*n;i++)
	{
		double a;
		cin>>a;
		int t = int(a*1000+0.1);
		sum -= t%1000;
		if(t%1000) k++;
	}
	solve();
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int sum,n,k;

void output(int a)
{
	printf("%d.%03d\n",a/1000,a%1000);
}

void solve()
{
	int a = sum + 1000 * max(0,k-n), b = sum + 1000 * min(n,k);
	if(b<=0) output(-b);
	else if(a>=0) output(a);
	else
	{
		b = b%1000;
		output(min(b,1000-b));
	}
}

int main()
{
	cin>>n;
	sum = 0; k = 0;
	for(int i=0;i<2*n;i++)
	{
		double a;
		cin>>a;
		int t = int(a*1000+0.1);
		sum -= t%1000;
		if(t%1000) k++;
	}
	solve();
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
using namespace std;

double sum;
int k;
int n;

double solve()
{
	double lf = max(0,k-n),rt = min(k,n);
	double a = sum-(n-lf),b= sum - (n-rt);
	if(b<=0) return fabs(-b);
	else if(a>=0) return fabs(a);
	double t = b - floor(b);
	return min(fabs(t),fabs(1-t));
}

int main()
{
	cin>>n;
	sum = 0; k  =0;
	for(int i=0;i<2*n;i++)
	{
		double a;
		cin>>a;
		sum += ceil(a)-a;
		if(ceil(a)==a) k++;
	}
	printf("%.3lf\n",solve());
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
using namespace std;

double sum;
int k;
int n;

double solve()
{
	double lf = max(0,k-n),rt = min(k,n);
	double a = sum-(n-lf),b= sum - (n-rt);
	if(b<=0) return -b;
	else if(a>=0) return a;
	double t = b - floor(b);
	return min(fabs(t),fabs(1-t));
}

int main()
{
    cin>>n;
	sum = 0; k  =0;
	for(int i=0;i<2*n;i++)
	{
		double a;
		cin>>a;
		sum += ceil(a)-a;
		if(ceil(a)==a) k++;
	}
	printf("%.3lf\n",solve());
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
using namespace std;
int sum;
int k;
int n;

int myabs(int a) {return a<0?-a:a;}

void output(int a)
{
	printf("%d.%03d\n",a/1000,a%1000);
}

void solve()
{
	int a = sum + 1000 * max(0,k-n), b = sum + 1000 * min(n,k);
	if(b<=0) output(myabs(b));
	else if(a>=0) output(myabs(a));
	else
	{
		a = a%1000;
		output(min(myabs(a),myabs(1000-a)));
	}
}

int main()
{
	cin>>n;
	sum = 0; k  = 0;
	for(int i=0;i<2*n;i++)
	{
		double a;
		cin>>a;
		int t = int(a*1000+0.1);
		sum -= t%1000;
		if(t%1000) k++;
	}
	solve();
	return 0;
}


#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#define N 2222
using namespace std;

double mas[N];

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n;
    cin >> n;
    int zeros = 0;
    vector<double> v;
    for (int i = 0; i < 2*n; ++i) {
        double a;
        cin >> a;
        if (!(((int)a) == a)) {
            v.push_back(a - (int)a);
        }
        else {
            ++zeros;
        }
    }

    if (v.empty()) {
        cout << "0.000" << endl;
        return 0;
    }
    sort(v.begin(), v.end());

    double diff = 100000000;
    vector<double> sums;
    sums.push_back(v[0]);
    for (size_t i = 1; i < v.size(); ++i) {
        sums.push_back(sums[i-1] + v[i]);
    }

    double S = sums[v.size()-1];

    for (int i = 0; i < sums.size(); ++i) {
        if (abs((int)sums.size() - 2*(i + 1)) <= zeros) {
            if (abs((i+1) - sums[i] - (S -sums[i])) < diff) {
                diff = abs((i+1) - sums[i] - (S -sums[i]));
            }

            if (abs(sums[i] - (sums.size() - (i+1) - (S - sums[i]))) < diff) {
                diff = abs(sums[i] - (sums.size() - (i+1) - (S - sums[i])));
            }
        }
    }

    cout.precision(3);
    cout << fixed;
    cout << diff;
    return 0;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <memory.h>
#include <limits>
#include <string>
#include <sstream>
#include <queue>
#include <stdlib.h>
#include <list>
#include <stack>

using namespace std;
typedef signed long long ll;
const char llf[] = "%I64d";

typedef std::vector<int> vint;
typedef std::vector<ll> vlint;
typedef std::vector< std::set<int> > mint;
typedef std::pair<int, int> point;

struct pred {
    bool operator()(double f1, double f2) {
        return abs(f1 - floor(f1)) < abs(f2 - floor(f2));
    }
};

struct dz {
    bool operator()(double d) {
        return abs(d-floor(d)) <= std::numeric_limits<double>::epsilon();
    }
};

int main()
{
    //freopen("D:\\test.txt", "rt", stdin);
    int n = 0;
    double a[20001] = {0.0000f};
    scanf("%d", &n);
    for (int i = 0; i != n*2; ++i)
        scanf("%lf", a+i);

    double before = std::accumulate(a, a+2*n, 0.000);
    std::sort(a, a+n*2, pred());
    int zeroes = (int)std::count_if(a,a+2*n, dz());
    if (zeroes > n) zeroes = n;

    int i = 0;
    int j = n*2 - 1;
    double after = 0;
    while (i - 1 < j
        && abs(a[i] - floor(a[i]))<=std::numeric_limits<double>::epsilon()
        && abs(a[i+1] - floor(a[i+1]))<=std::numeric_limits<double>::epsilon())
    { after += a[i] + a[i+1]; i+=2; }
    while (i < j) {
        after += floor(a[i++]) + ceil(a[j--]);
    }

        while (zeroes>1 && (before-after > 0.5)) {
            zeroes-=2;
            ++after;
        }

        while (zeroes>=1 && (before-after) < -0.5) {
            zeroes-=2;
            --after;
        }

    printf("%.3f", abs(before - after));
    return 0;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <memory.h>
#include <limits>
#include <string>
#include <sstream>
#include <queue>
#include <stdlib.h>
#include <list>
#include <stack>

using namespace std;
typedef signed long long ll;
const char llf[] = "%I64d";

typedef std::vector<int> vint;
typedef std::vector<ll> vlint;
typedef std::vector< std::set<int> > mint;
typedef std::pair<int, int> point;

struct pred {
    bool operator()(double f1, double f2) {
        return (f1 - floor(f1)) < (f2 - floor(f2));
    }
};

int main()
{
    //freopen("E:\\test.txt", "rt", stdin);
    int n = 0;
    double a[20001] = {0.0000f};
    scanf("%d", &n);
    for (int i = 0; i != n*2; ++i)
        scanf("%lf", a+i);

    double before = 0.0f;
    for (int i = 0; i != 2*n; ++i) {
        before += a[i];
    }

    double ans = n == 1 ? before -floor(before) : min(before -floor(before), ceil(before) - before);
    printf("%.3f", ans);
    return 0;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <memory.h>
#include <limits>
#include <string>
#include <sstream>
#include <queue>
#include <stdlib.h>
#include <list>
#include <stack>

using namespace std;
typedef signed long long ll;
const char llf[] = "%I64d";

typedef std::vector<int> vint;
typedef std::vector<ll> vlint;
typedef std::vector< std::set<int> > mint;
typedef std::pair<int, int> point;

struct pred {
    bool operator()(double f1, double f2) {
        return abs(f1 - floor(f1)) < abs(f2 - floor(f2));
    }
};

struct dz {
    bool operator()(double d) {
        return abs(d-floor(d)) < std::numeric_limits<double>::epsilon();
    }
};

int main()
{
    //freopen("D:\\test.txt", "rt", stdin);
    int n = 0;
    double a[20001] = {0.0000f};
    scanf("%d", &n);
    for (int i = 0; i != n*2; ++i)
        scanf("%lf", a+i);

    double before = std::accumulate(a, a+2*n, 0.000);
    std::sort(a, a+n*2, pred());
    int zeroes = (int)std::count_if(a,a+2*n, dz());
    if (zeroes > n) zeroes = n;

    int i = 0;
    int j = n*2 - 1;
    double after = 0;
    while (i - 1 < j
        && abs(a[i] - floor(a[i]))<std::numeric_limits<double>::epsilon()
        && abs(a[i+1] - floor(a[i+1]))<std::numeric_limits<double>::epsilon())
    { after += a[i] + a[i+1]; i+=2; }
    while (i < j) {
        after += floor(a[i++]) + ceil(a[j--]);
    }

    while (zeroes && (before-after > 0.5)) {
        --zeroes;
        ++after;
    }

    while (zeroes && (before-after) < -0.5) {
        --zeroes;
        --after;
    }

    printf("%.3f", abs(before - after));
    return 0;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <memory.h>
#include <limits>
#include <string>
#include <sstream>
#include <queue>
#include <stdlib.h>
#include <list>
#include <stack>

using namespace std;
typedef signed long long ll;
const char llf[] = "%I64d";

typedef std::vector<int> vint;
typedef std::vector<ll> vlint;
typedef std::vector< std::set<int> > mint;
typedef std::pair<int, int> point;

struct pred {
    bool operator()(double f1, double f2) {
        return abs(f1 - floor(f1)) < abs(f2 - floor(f2));
    }
};

struct dz {
    bool operator()(double d) {
        return abs(d-floor(d)) <= std::numeric_limits<double>::epsilon();
    }
};

int main()
{
    //freopen("D:\\test.txt", "rt", stdin);
    int n = 0;
    double a[20001] = {0.0000f};
    scanf("%d", &n);
    for (int i = 0; i != n*2; ++i)
        scanf("%lf", a+i);

    double before = std::accumulate(a, a+2*n, 0.000);
    std::sort(a, a+n*2, pred());
    int zeroes = (int)std::count_if(a,a+2*n, dz());
    if (zeroes > n) zeroes = n;

    int i = 0;
    int j = n*2 - 1;
    double after = 0;
    while (i - 1 < j
        && abs(a[i] - floor(a[i]))<=std::numeric_limits<double>::epsilon()
        && abs(a[i+1] - floor(a[i+1]))<=std::numeric_limits<double>::epsilon())
    { after += a[i] + a[i+1]; i+=2; }
    while (i < j) {
        after += floor(a[i++]) + ceil(a[j--]);
    }

    while (zeroes) {
        while (zeroes && (before-after > 0.5)) {
            zeroes-=2;
            ++after;
        }

        while (zeroes && (before-after) < -0.5) {
            zeroes-=2;
            --after;
        }
    }

    printf("%.3f", abs(before - after));
    return 0;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <memory.h>
#include <limits>
#include <string>
#include <sstream>
#include <queue>
#include <stdlib.h>
#include <list>
#include <stack>

using namespace std;
typedef signed long long ll;
const char llf[] = "%I64d";

typedef std::vector<int> vint;
typedef std::vector<ll> vlint;
typedef std::vector< std::set<int> > mint;
typedef std::pair<int, int> point;

struct pred {
    bool operator()(double f1, double f2) {
        return (f1 - floor(f1)) < (f2 - floor(f2));
    }
};

struct dz {
    bool operator()(double d) {
        return abs(d-floor(d)) < std::numeric_limits<double>::epsilon();
    }
};

int main()
{
    //freopen("D:\\test.txt", "rt", stdin);
    int n = 0;
    double a[20001] = {0.0000f};
    scanf("%d", &n);
    for (int i = 0; i != n*2; ++i)
        scanf("%lf", a+i);

    double before = std::accumulate(a, a+2*n, 0.000);
    std::sort(a, a+n*2, pred());
    int zeroes = (int)std::count_if(a,a+2*n, dz());
    if (zeroes > n) zeroes = n;

    int i = 0;
    int j = n*2 - 1;
    double after = 0;
    while (i - 1 < j
        && abs(a[i] - floor(a[i]))<std::numeric_limits<double>::epsilon()
        && abs(a[i+1] - floor(a[i+1]))<std::numeric_limits<double>::epsilon())
    { after += a[i] + a[i+1]; i+=2; }
    while (i < j) {
        after += floor(a[i]) + ceil(a[j--]);
    }

    while (zeroes && (before-after > 0.5)) {
        --zeroes;
        ++after;
    }

    while (zeroes && (before-after) < -0.5) {
        --zeroes;
        --after;
    }

    printf("%.3f", abs(before - after));
    return 0;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <memory.h>
#include <limits>
#include <string>
#include <sstream>
#include <queue>
#include <stdlib.h>
#include <list>
#include <stack>

using namespace std;
typedef signed long long ll;
const char llf[] = "%I64d";

typedef std::vector<int> vint;
typedef std::vector<ll> vlint;
typedef std::vector< std::set<int> > mint;
typedef std::pair<int, int> point;

struct pred {
    bool operator()(double f1, double f2) {
        return (f1 - floor(f1)) < (f2 - floor(f2));
    }
};

int main()
{
    //freopen("E:\\test.txt", "rt", stdin);
    int n = 0;
    double a[20001] = {0.0000f};
    scanf("%d", &n);
    for (int i = 0; i != n*2; ++i)
        scanf("%lf", a+i);

    double before = 0.0f;
    for (int i = 0; i != 2*n; ++i) {
        before += a[i];
    }

    double ans = min(before -floor(before), ceil(before) - before);
    printf("%.3f", ans);
    return 0;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <memory.h>
#include <limits>
#include <string>
#include <sstream>
#include <queue>
#include <stdlib.h>
#include <list>
#include <stack>

using namespace std;
typedef signed long long ll;
const char llf[] = "%I64d";

typedef std::vector<int> vint;
typedef std::vector<ll> vlint;
typedef std::vector< std::set<int> > mint;
typedef std::pair<int, int> point;

struct pred {
    bool operator()(double f1, double f2) {
        return abs(f1 - floor(f1)) < abs(f2 - floor(f2));
    }
};

struct dz {
    bool operator()(double d) {
        return abs(d-floor(d)) <= std::numeric_limits<double>::epsilon();
    }
};

int main()
{
    //freopen("D:\\test.txt", "rt", stdin);
    int n = 0;
    double a[20001] = {0.0000f};
    scanf("%d", &n);
    for (int i = 0; i != n*2; ++i)
        scanf("%lf", a+i);

    double before = std::accumulate(a, a+2*n, 0.000);
    std::sort(a, a+n*2, pred());
    int zeroes = (int)std::count_if(a,a+2*n, dz());
    if (zeroes > n) zeroes = n;

    int i = 0;
    int j = n*2 - 1;
    double after = 0;
    while (i - 1 < j
        && abs(a[i] - floor(a[i]))<=std::numeric_limits<double>::epsilon()
        && abs(a[i+1] - floor(a[i+1]))<=std::numeric_limits<double>::epsilon())
    { after += a[i] + a[i+1]; i+=2; }
    while (i < j) {
        after += floor(a[i++]) + ceil(a[j--]);
    }

        while (zeroes>0 && (before-after > 0.5)) {
            zeroes-=2;
            ++after;
        }

        while (zeroes>0 && (before-after) < -0.5) {
            zeroes-=2;
            --after;
        }

    printf("%.3f", abs(before - after));
    return 0;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <memory.h>
#include <limits>
#include <string>
#include <sstream>
#include <queue>
#include <stdlib.h>
#include <list>
#include <stack>

using namespace std;
typedef signed long long ll;
const char llf[] = "%I64d";

typedef std::vector<int> vint;
typedef std::vector<ll> vlint;
typedef std::vector< std::set<int> > mint;
typedef std::pair<int, int> point;

struct pred {
    bool operator()(double f1, double f2) {
        return (f1 - floor(f1)) < (f2 - floor(f2));
    }
};

struct dz {
    bool operator()(double d) {
        return abs(d-floor(0.5+d)) < std::numeric_limits<double>::epsilon();
    }
};

int main()
{
    //freopen("D:\\test.txt", "rt", stdin);
    int n = 0;
    double a[20001] = {0.0000f};
    scanf("%d", &n);
    for (int i = 0; i != n*2; ++i)
        scanf("%lf", a+i);

    double before = std::accumulate(a, a+2*n, 0.000);
    std::sort(a, a+n*2, pred());
    int zeroes = (int)std::count_if(a,a+2*n, dz());
    if (zeroes > n) zeroes = n;

    int i = 0;
    int j = n*2 - 1;
    double after = 0;
    while (i - 1 < j
        && abs(a[i] - floor(a[i]))<std::numeric_limits<double>::epsilon()
        && abs(a[i+1] - floor(a[i+1]))<std::numeric_limits<double>::epsilon())
    { after += a[i] + a[i+1]; i+=2; }
    while (i < j) {
        after += floor(a[i++]) + ceil(a[j--]);
    }

    while (zeroes && (before-after > 0.5)) {
        --zeroes;
        ++after;
    }

    while (zeroes && (before-after) < -0.5) {
        --zeroes;
        --after;
    }

    printf("%.3f", abs(before - after));
    return 0;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <memory.h>
#include <limits>
#include <string>
#include <sstream>
#include <queue>
#include <stdlib.h>
#include <list>
#include <stack>

using namespace std;
typedef signed long long ll;
const char llf[] = "%I64d";

typedef std::vector<int> vint;
typedef std::vector<ll> vlint;
typedef std::vector< std::set<int> > mint;
typedef std::pair<int, int> point;

struct pred {
    bool operator()(double f1, double f2) {
        return abs(f1 - floor(f1)) < abs(f2 - floor(f2));
    }
};

struct dz {
    bool operator()(double d) {
        return abs(d-floor(0.5+d)) < std::numeric_limits<double>::epsilon();
    }
};

int main()
{
   // freopen("D:\\test.txt", "rt", stdin);
    int n = 0;
    double a[20001] = {0.0000f};
    scanf("%d", &n);
    for (int i = 0; i != n*2; ++i)
        scanf("%lf", a+i);

    double before = std::accumulate(a, a+2*n, 0.000);
    std::sort(a, a+n*2, pred());
    int zeroes = (int)std::count_if(a,a+2*n, dz());
    if (zeroes > n) zeroes = n;

    int i = 0;
    int j = n*2 - 1;
    double after = 0;
    while (i - 1 < j
        && abs(a[i] - floor(a[i]+0.1))<std::numeric_limits<double>::epsilon()
        && abs(a[i+1] - floor(a[i+1]+0.1))<std::numeric_limits<double>::epsilon())
    { after += a[i] + a[i+1]; i+=2; }
    while (i < j) {
        after += floor(a[i++]) + ceil(a[j--]);
    }

    while (zeroes && (before-after > 0.5)) {
        --zeroes;
        ++after;
    }

    while (zeroes && (before-after) < -0.5) {
        --zeroes;
        --after;
    }

    printf("%.3f", abs(before - after));
    return 0;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <memory.h>
#include <limits>
#include <string>
#include <sstream>
#include <queue>
#include <stdlib.h>
#include <list>
#include <stack>

using namespace std;
typedef signed long long ll;
const char llf[] = "%I64d";

typedef std::vector<int> vint;
typedef std::vector<ll> vlint;
typedef std::vector< std::set<int> > mint;
typedef std::pair<int, int> point;

struct pred {
    bool operator()(double f1, double f2) {
        return (f1 - floor(f1)) < (f2 - floor(f2));
    }
};

struct dz {
    bool operator()(double d) {
        return abs(d-floor(0.5+d)) < std::numeric_limits<double>::epsilon();
    }
};

int main()
{
    //freopen("D:\\test.txt", "rt", stdin);
    int n = 0;
    double a[20001] = {0.0000f};
    scanf("%d", &n);
    for (int i = 0; i != n*2; ++i)
        scanf("%lf", a+i);

    double before = std::accumulate(a, a+2*n, 0.000);
    std::sort(a, a+n*2, pred());
    int zeroes = (int)std::count_if(a,a+2*n, dz());
    if (zeroes > n) zeroes = n;

    int i = 0;
    int j = n*2 - 1;
    double after = 0;
    while (i - 1 < j
        && abs(a[i] - floor(0.5+a[i]))<std::numeric_limits<double>::epsilon()
        && abs(a[i+1] - floor(0.5+a[i+1]))<std::numeric_limits<double>::epsilon())
    { after += a[i] + a[i+1]; i+=2; }
    while (i < j) {
        after += floor(a[i]) + ceil(a[j--]);
    }

    while (zeroes && (before-after > 0.5)) {
        --zeroes;
        ++after;
    }

    while (zeroes && (before-after) < -0.5) {
        --zeroes;
        --after;
    }

    printf("%.3f", abs(before - after));
    return 0;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <memory.h>
#include <limits>
#include <string>
#include <sstream>
#include <queue>
#include <stdlib.h>
#include <list>
#include <stack>

using namespace std;
typedef signed long long ll;
const char llf[] = "%I64d";

typedef std::vector<int> vint;
typedef std::vector<ll> vlint;
typedef std::vector< std::set<int> > mint;
typedef std::pair<int, int> point;

struct pred {
    bool operator()(double f1, double f2) {
        return abs(f1 - floor(f1+0.1)) < abs(f2 - floor(f2+0.1));
    }
};

struct dz {
    bool operator()(double d) {
        return abs(d-floor(0.5+d)) < std::numeric_limits<double>::epsilon();
    }
};

int main()
{
    //freopen("D:\\test.txt", "rt", stdin);
    int n = 0;
    double a[20001] = {0.0000f};
    scanf("%d", &n);
    for (int i = 0; i != n*2; ++i)
        scanf("%lf", a+i);

    double before = std::accumulate(a, a+2*n, 0.000);
    std::sort(a, a+n*2, pred());
    int zeroes = (int)std::count_if(a,a+2*n, dz());
    if (zeroes > n) zeroes = n;

    int i = 0;
    int j = n*2 - 1;
    double after = 0;
    while (i - 1 < j
        && abs(a[i] - floor(a[i]+0.1))<std::numeric_limits<double>::epsilon()
        && abs(a[i+1] - floor(a[i+1]+0.1))<std::numeric_limits<double>::epsilon())
    { after += a[i] + a[i+1]; i+=2; }
    while (i < j) {
        after += floor(a[i++]) + ceil(a[j--]);
    }

    while (zeroes && (before-after > 0.5)) {
        --zeroes;
        ++after;
    }

    while (zeroes && (before-after) < -0.5) {
        --zeroes;
        --after;
    }

    printf("%.3f", abs(before - after));
    return 0;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <memory.h>
#include <limits>
#include <string>
#include <sstream>
#include <queue>
#include <stdlib.h>
#include <list>
#include <stack>

using namespace std;
typedef signed long long ll;
const char llf[] = "%I64d";

typedef std::vector<int> vint;
typedef std::vector<ll> vlint;
typedef std::vector< std::set<int> > mint;
typedef std::pair<int, int> point;

struct pred {
    bool operator()(double f1, double f2) {
        return (f1 - floor(f1)) < (f2 - floor(f2));
    }
};

int main()
{
    //freopen("E:\\test.txt", "rt", stdin);
    int n = 0;
    double a[20001] = {0.0000f};
    scanf("%d", &n);
    for (int i = 0; i != n*2; ++i)
        scanf("%lf", a+i);

    double before = 0.0f;
    for (int i = 0; i != 2*n; ++i) {
        before += a[i];
    }
    std::sort(a, a+n*2, pred());
    int i = 0;
    int j = n*2 - 1;
    double after = 0;
    while (i - 1 < j
        && abs(a[i] - floor(a[i]))<std::numeric_limits<double>::epsilon()
        && abs(a[i+1] - floor(a[i+1]))<std::numeric_limits<double>::epsilon())
    { after += a[i] + a[i+1]; i+=2; }
    while (i < j) {
        after += floor(a[i++]) + ceil(a[j--]);
    }
    printf("%.3f", abs(before - after));
    return 0;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <memory.h>
#include <limits>
#include <string>
#include <sstream>
#include <queue>
#include <stdlib.h>
#include <list>
#include <stack>

using namespace std;
typedef signed long long ll;
const char llf[] = "%I64d";

typedef std::vector<int> vint;
typedef std::vector<ll> vlint;
typedef std::vector< std::set<int> > mint;
typedef std::pair<int, int> point;

struct pred {
    bool operator()(double f1, double f2) {
        return (f1 - floor(f1)) < (f2 - floor(f2));
    }
};

struct dz {
    bool operator()(double d) {
        return abs(d-floor(0.5+d)) < std::numeric_limits<double>::epsilon();
    }
};

int main()
{
    //freopen("D:\\test.txt", "rt", stdin);
    int n = 0;
    double a[20001] = {0.0000f};
    scanf("%d", &n);
    for (int i = 0; i != n*2; ++i)
        scanf("%lf", a+i);

    double before = std::accumulate(a, a+2*n, 0.000);
    std::sort(a, a+n*2, pred());
    int zeroes = (int)std::count_if(a,a+2*n, dz());
    if (zeroes > n) zeroes = n;

    int i = 0;
    int j = n*2 - 1;
    double after = 0;
    while (i - 1 < j
        && abs(a[i] - floor(a[i]))<std::numeric_limits<double>::epsilon()
        && abs(a[i+1] - floor(a[i+1]))<std::numeric_limits<double>::epsilon())
    { after += a[i] + a[i+1]; i+=2; }
    while (i < j) {
        after += floor(a[i++]) + ceil(a[j--]);
    }

    while (zeroes && (before-after > 0.5)) {
        --zeroes;
        ++after;
    }

    printf("%.3f", abs(before - after));
    return 0;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <memory.h>
#include <limits>
#include <string>
#include <sstream>
#include <queue>
#include <stdlib.h>
#include <list>
#include <stack>

using namespace std;
typedef signed long long ll;
const char llf[] = "%I64d";

typedef std::vector<int> vint;
typedef std::vector<ll> vlint;
typedef std::vector< std::set<int> > mint;
typedef std::pair<int, int> point;

struct pred {
    bool operator()(double f1, double f2) {
        return abs(f1 - floor(f1)) < abs(f2 - floor(f2));
    }
};

struct dz {
    bool operator()(double d) {
        return abs(d-floor(d)) <= std::numeric_limits<double>::epsilon();
    }
};

int main()
{
    //freopen("D:\\test.txt", "rt", stdin);
    int n = 0;
    double a[20001] = {0.0000f};
    scanf("%d", &n);
    for (int i = 0; i != n*2; ++i)
        scanf("%lf", a+i);

    double before = std::accumulate(a, a+2*n, 0.000);
    std::sort(a, a+n*2, pred());
    int zeroes = (int)std::count_if(a,a+2*n, dz());
    if (zeroes > n) zeroes = n;

    int i = 0;
    int j = n*2 - 1;
    double after = 0;
    while (i - 1 < j
        && abs(a[i] - floor(a[i]))<=std::numeric_limits<double>::epsilon()
        && abs(a[i+1] - floor(a[i+1]))<=std::numeric_limits<double>::epsilon())
    { after += a[i] + a[i+1]; i+=2; }
    while (i < j) {
        after += floor(a[i++]) + ceil(a[j--]);
    }

        while (zeroes>1 && (before-after > 0.5)) {
            zeroes-=2;
            ++after;
        }

        while (zeroes>1 && (before-after) < -0.5) {
            zeroes-=2;
            --after;
        }

    printf("%.3f", abs(before - after));
    return 0;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <memory.h>
#include <limits>
#include <string>
#include <sstream>
#include <queue>
#include <stdlib.h>
#include <list>
#include <stack>

using namespace std;
typedef signed long long ll;
const char llf[] = "%I64d";

typedef std::vector<int> vint;
typedef std::vector<ll> vlint;
typedef std::vector< std::set<int> > mint;
typedef std::pair<int, int> point;

struct pred {
    bool operator()(double f1, double f2) {
        return (f1 - floor(f1)) < (f2 - floor(f2));
    }
};

int main()
{
    //freopen("E:\\test.txt", "rt", stdin);
    int n = 0;
    double a[20001] = {0.0000f};
    scanf("%d", &n);
    for (int i = 0; i != n*2; ++i)
        scanf("%lf", a+i);

    double before = 0.0f;
    for (int i = 0; i != 2*n; ++i) {
        before += a[i];
    }

    double ans = (n == 1 && abs(a[0]-floor(a[0]))>std::numeric_limits<double>::epsilon()&& abs(a[1]-floor(a[1]))>std::numeric_limits<double>::epsilon())
        ? before -floor(before) : min(before -floor(before), ceil(before) - before);
    printf("%.3f", ans);
    return 0;
}


#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    int n;
    cin >> n;

    double frac_sum = 0.0;
    int num_int = 0;
    for(int i = 0; i < 2*n; ++i) {
        double x;
        cin >> x;

        frac_sum += x - floor(x);

        if(fabs(x - (int)x) < 1e-5)
            ++num_int;
    }

    double ans = 1e10;
    for(int i = max(0, n - num_int); i <= min(n, 2*n - num_int); ++i)
        ans = min(ans, fabs(i - frac_sum));

    cout << fixed << setprecision(3) << ans;

    return 0;
}

/*
*/


#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    int n;
    cin >> n;

    double frac_sum = 0.0;
    int num_int = 0;
    for(int i = 0; i < 2*n; ++i) {
        double x;
        cin >> x;

        frac_sum += x - floor(x);

        if(fabs(x - (int)x) < 1e-5)
            ++num_int;
    }

    double ans = 1e10;
    for(int i = 0; i <= min(n, 2*n - num_int); ++i)
        ans = min(ans, fabs(i - frac_sum));

    cout << fixed << setprecision(3) << ans;

    return 0;
}