#include <iostream>

using namespace std;

int main()
{
    int N, a, b, c;
    cin >> N;
    cin >> a;
    cin >> b;
    cin >> c;
    if (N == 2)
    {
        if (a > b)
        {
            cout << a;
            return 0;
        }
        else
        {
            cout << b;
            return 0;
        }
    }
    if (N == 3)
    {
     if (a == b &  b >= c)
     {
         cout << a;
         return 0;
     }
     if (a == b &  b < c)
     {
         cout << c;
         return 0;
     }
     if (a == c &  b >= c)
     {
         cout << b;
         return 0;
     }
     if (a == c &  b < c)
     {

         cout << a;
         return 0;
     }
     if (a > b &  b > c)
     {
         cout << a;
         return 0;
     }
     if (a > c &  c > b)
     {
         cout << a + c - b;
         return 0;
     }
     if (b > c &  c > a)
     {
         cout << b;
         return 0;
     }
     if (b > a &  a > c)
     {
         cout << b;
         return 0;
     }
     if (c > b &  b > a)
     {
         cout << c;
         return 0;
     }
     if (c > a & a > b)
     {
         cout << c + a - b;
         return 0;
     }
    }
    return 0;
}
