#include <bits/stdc++.h>   using namespace std;   void input(long &n) { scanf( %ld , &n); }   void output(long n) { printf( %ld , n); }   void input(long &n, long a[]) {     input(n);     for (long i = 1; i <= n; i++) input(a[i]);   }   bool test(long n, long a[], long id1, long id2, long tid, vector<long> &st1,             vector<long> &st2) {     st1.clear();     st2.clear();     st1.push_back(a[id1]);     st1.push_back(a[id2]);     long isize2;     if (tid == -1) {       isize2 = 0;     } else {       isize2 = 1;       st2.push_back(a[tid]);     }     long seed = a[id2] - a[id1];     long seed2 = 0;     long nextnum2 = 0;     long nextnum = a[id2] + seed;     for (long i = id2 + 1; i <= n; i++) {       if (isize2 >= 2 && a[i] == nextnum && a[i] == nextnum2) {         if (i == n) {           nextnum += seed;           st1.push_back(a[i]);         } else if (nextnum + seed == a[i + 1]) {           nextnum += seed;           st1.push_back(a[i]);         } else if (nextnum2 + seed2 == a[i + 1]) {           st2.push_back(a[i]);           nextnum2 += seed2;           isize2++;         } else           return false;       } else if (a[i] == nextnum) {         nextnum += seed;         st1.push_back(a[i]);       } else {         if (isize2 >= 2) {           if (nextnum2 == a[i]) {             st2.push_back(a[i]);             isize2++;             nextnum2 += seed2;           } else if (isize2 == 2) {             st2.push_back(st2[1]);             isize2++;             st2[1] = st1.back();             st1.pop_back();             if (st2[2] - st2[1] != st2[1] - st2[0]) return false;             seed2 = st2[2] - st2[1];             nextnum2 = st2[2] + seed2;             i--;           } else             return false;         } else {           st2.push_back(a[i]);           isize2++;           if (isize2 == 2) {             seed2 = st2[1] - st2[0];             nextnum2 = st2[1] + seed2;           }         }       }     }     if (seed == 0 && st1.size() > 2) return false;     if (seed2 == 0 && st2.size() > 2) return false;     if (isize2 == 0) return false;     return true;   }   bool solve(long n, long a[], vector<long> &st1, vector<long> &st2) {     if (n == 2) {       st1.push_back(a[1]);       st2.push_back(a[2]);       return true;     } else if (n == 3 && a[1] == a[2] && a[2] == a[3]) {       st1.push_back(a[1]);       st1.push_back(a[1]);       st2.push_back(a[1]);       return true;     } else if (n == 4 && a[1] == a[2] && a[2] == a[3] && a[3] == a[4]) {       st1.push_back(a[1]);       st1.push_back(a[1]);       st2.push_back(a[1]);       st2.push_back(a[1]);       return true;     }     if (test(n, a, 1, 3, 2, st1, st2)) return true;     if (test(n, a, 2, 3, 1, st1, st2)) return true;     if (test(n, a, 1, 2, -1, st1, st2)) return true;     return false;   }   void output(bool res, vector<long> &st1, vector<long> &st2) {     if (res) {       for (vector<long>::iterator it = st1.begin(); it < st1.end(); it++)         printf( %ld  , *it);       printf(  n );       for (vector<long>::iterator it = st2.begin(); it < st2.end(); it++)         printf( %ld  , *it);     } else       cout <<  No solution n ;   }   long n, a[30010 + 1];   vector<long> st1, st2;   int main() {     input(n, a);     bool res = solve(n, a, st1, st2);     output(res, st1, st2);   }