public void solve() throws IOException {
    int n = nextInt();
    ArrayList<Integer> data = new ArrayList<Integer>();
    for (int x = 0; x < n; x++)
      data.add(nextInt());

    while (!isSorted(data)) {
      int maxcount = 0;
      int del = -1;
      for (int x = 0; x < data.size(); x++) {
        int count = 0;
        for (int y = 0; y < data.size(); y++) {
          if (x < y && data.get(x) > data.get(y))
            count++;
          if (x > y && data.get(x) < data.get(y))
            count++;
        }
        if (count > maxcount) {
          del = x;
          maxcount = count;
        }
      }
      data.remove(del);
    }
    out.println(data.size());
  }