#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    cout << "n:";
    int n;
    cin >> n;
    cout << "cards:";
    int* pA = new int[n];
    for(int i=0; i<n; i++)
    {
        cin >> pA[i];
    }
    int* pB = new int[n];
    int sum = 0;
    int x = 0;
    int y = 0;
    for(int i=0; i<n; i++)
    {
        sum += pA[i];
    }
    int current = abs(sum - pA[0]);
    int min = current;
    for(int i=0;i<n-1;i++)
    {
        pB[i] = pA[i];
        x += pB[i];
        y = sum - x;
        current = abs(x-y);
        if(current < min)
            min = current;
    }

    cout << "minimum: " << min;

    delete [] pA;
    delete [] pB;
    return 0;
}
