#include <iostream>

int* removeDuplicates(int* arr, int size, int& newSize) {
    int* uniqueArr = new int[size];
    int uniqueCount = 0;

    for (int i = 0; i < size; ++i) {
        bool isDuplicate = false;
        for (int j = 0; j < uniqueCount; ++j) {
            if (uniqueArr[j] == arr[i]) {
                isDuplicate = true;
                break;
            }
        }
        if (!isDuplicate) {
            uniqueArr[uniqueCount++] = arr[i];
        }
    }

    newSize = uniqueCount;
    return uniqueArr;
}

int main() {
    int arr[] = {1, 2, 2, 3, 4, 4, 4, 5};
    int size = sizeof(arr) / sizeof(arr[0]);
    int newSize;


    int* uniqueArr = removeDuplicates(arr, size, newSize);

    std::cout << "{";
    for (int i = 0; i < newSize; ++i) {
        std::cout << uniqueArr[i];
        if (i < newSize - 1) {
            std::cout << ", ";
        }
    }
    std::cout << "}" << std::endl;

    delete[] uniqueArr;

    return 0;
}

