Rewrite this code with using array of elements instead of vector: #include <iostream>
#include <vector>

using namespace std;

class Element {
public:
    int priority;
    int value;
};

class queue {
private:
    int highestpriority() {
        int highest = 0;
        for (int i = 1; i < elements.size(); i++) {
            if (elements[highest].priority < elements[i].priority) {
                highest = i;
            }
        }
        return highest;
    }

public:
    vector<Element> elements;

    void enqueue(int priority, int value) {
        Element newel;
        newel.priority = priority;
        newel.value = value;
        int buffv, buffp,flag=0;
        elements.push_back(newel);
            for (int i = elements.size()-1; i > -1; i--) {
                if (flag == 0) {
                    if ((elements[i].priority > elements[elements.size() - 1].priority)) {
                        flag = 1;
                    }
                    else {
                        if ((i == 0) && (elements[i].priority < elements[elements.size() - 1].priority)) {
                            for (int j = elements.size() - 1; j > i; j--) {
                                buffv = elements[j].value;
                                buffp = elements[j].priority;
                                elements[j].value = elements[j - 1].value;
                                elements[j].priority = elements[j - 1].priority;
                                elements[j - 1].value = buffv;
                                elements[j - 1].priority = buffp;
                                flag = 1;
                            }
                        }
                        if ((elements[i].priority < elements[elements.size() - 1].priority) && (elements[i-1].priority > elements[elements.size() - 1].priority)) {
                            for (int j = elements.size() - 1; j > i; j--) {
                                buffv = elements[j].value;
                                buffp = elements[j].priority;
                                elements[j].value = elements[j - 1].value;
                                elements[j].priority = elements[j - 1].priority;
                                elements[j - 1].value = buffv;
                                elements[j - 1].priority = buffp;
                                flag = 1;
                            }
                        }
                        if ((elements[i].priority == elements[elements.size() - 1].priority)) {
                            for (int j = elements.size() - 1; j > i + 1; j--) {
                                buffv = elements[j].value;
                                buffp = elements[j].priority;
                                elements[j].value = elements[j - 1].value;
                                elements[j].priority = elements[j - 1].priority;
                                elements[j - 1].value = buffv;
                                elements[j - 1].priority = buffp;
                                flag = 1;
                            }
                        }
                    }
                }
            }
    }

    Element wthdrw(int index) {
        return elements[index];
    }

    Element unqueue() {
        int highestindex = highestpriority();
        Element result = elements[highestindex];
        if (elements.empty()) {
            cout << "Очередь пустая\n";
            return result;
        }
        elements.erase(elements.begin() + highestindex);
        return result;
    }

    bool isclear() {
        return elements.empty();
    }
};

int main() {
    setlocale(LC_ALL, "rus");
    queue queue1;
    queue1.enqueue(1, 10);
    queue1.enqueue(5, 30);
    queue1.enqueue(5, 20);
    queue1.enqueue(1, 40);
    queue1.enqueue(5, 25);
    queue1.enqueue(3, 50);
    for (int i = 0; i < queue1.elements.size(); i++) {
        cout << "Элемент под индексом " << i+1 << " имеет значение " << queue1.wthdrw(i).value << " и приоритет " << queue1.wthdrw(i).priority << endl;
    }
    cout << endl;
    while (!queue1.isclear()) {
        Element earliestelement = queue1.unqueue();
        cout << "Элемент вышел. Приоритет элемента - " << earliestelement.priority << " , значение элемента - " << earliestelement.value << endl;
    }
    return 0;
}