public static int[] normalize(int[] a)
    {
        int len = a.length;
        for (int i = 1; i < len; i++) //ugly way to iterate over len's devisors
        {
            if (len % i == 0)
            {
                boolean cannot_be_cut = false;
                for (int j = 0; j<i; j++)
                {
                    for(int k = 1; k < (len/i); k++)
                    {
                        if(a[j] != a[(j+i*k)%len])
                        {
                            cannot_be_cut = true;
                            break;
                        }
                    }
                    if (cannot_be_cut)
                    {
                        break;
                    }
                }
                if (!cannot_be_cut)
                {
                    int[] aa = new int[i];
                    for(int j = 0; j<i; j++)
                        aa[j] = a[j];
                    return order(aa);
                }
            }
        }
        return order(a);
    }