#include <iostream>
using namespace std;
int main() {
int n; long long j, sj, bj; // цены прыжка, суперприема и 3-го типа прыжка
cin >> n;
int platforms[n]; long long energy[n]; // создаем массивы для платформ и энергии
for (int i = 0; i < n; ++i) {
cin >> platforms[i]; //считываем высоты платформ
}
energy[0] = 0;
for (int i = 1; i < n; ++i) {
// обычный прыжок
j = (platforms[i] - platforms[i-1]) * (platforms[i] - platforms[i-1]);
// 3-й тип прыжка
bj = (platforms[i] - platforms[i+1]) * (platforms[i] - platforms[i+1]) +
3 * (platforms[i+1] - platforms[i-1]) * (platforms[i+1] - platforms[i-1]);
// суперприём
if (i == 1) sj = max(j, bj);
else sj = 3 * (platforms[i] - platforms[i-2]) * (platforms[i] - platforms[i-2]);
if (i == n-1) bj = max(j, sj);
//количество энергии на i-й платформе
if(i == 1) energy[i] = min(energy[i-1] + bj, energy[i-1] + j);
else energy[i] = min(energy[i-1] + bj, min(energy[i-1] + j, energy[i-2] + sj));
cout<<energy[i]<<endl;
}
cout << energy[n-1];
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgbjsgbG9uZyBsb25nIGosIHNqLCBiajsgLy8g0YbQtdC90Ysg0L/RgNGL0LbQutCwLCDRgdGD0L/QtdGA0L/RgNC40LXQvNCwINC4IDMt0LPQviDRgtC40L/QsCDQv9GA0YvQttC60LAKCWNpbiA+PiBuOwoJaW50IHBsYXRmb3Jtc1tuXTsgbG9uZyBsb25nIGVuZXJneVtuXTsgLy8g0YHQvtC30LTQsNC10Lwg0LzQsNGB0YHQuNCy0Ysg0LTQu9GPINC/0LvQsNGC0YTQvtGA0Lwg0Lgg0Y3QvdC10YDQs9C40LgKCQoJZm9yIChpbnQgaSA9IDA7IGkgPCBuOyArK2kpIHsKCQljaW4gPj4gcGxhdGZvcm1zW2ldOyAvL9GB0YfQuNGC0YvQstCw0LXQvCDQstGL0YHQvtGC0Ysg0L/Qu9Cw0YLRh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