Caisa solved the problem with the sugar and now he is on the way back to home. 

Caisa is playing a mobile game during his path. There are (n + 1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (i > 0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be k + 1). When the player have made such a move, its energy increases by hk - hk + 1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. 

Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game?

Input

The first line contains integer n (1 ≤ n ≤ 105). The next line contains n integers h1, h2, ..., hn (1 ≤ hi ≤ 105) representing the heights of the pylons.

Output

Print a single number representing the minimum number of dollars paid by Caisa.

Examples

Input

5
3 4 3 2 4


Output

4


Input

3
4 4 4


Output

4

Note

In the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon.
#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <class T>
void __printArray(T ara[], long long seez) {
  cerr << "{ ";
  for (long long i = 0; i < seez; i++) {
    cerr << ara[i];
    if (i != seez - 1) cerr << ",";
  }
  cerr << " }\n";
}
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
const int big = INT_MAX;
const int smol = INT_MIN;
const long long mod = 1e9 + 7;
const int INT5 = 1e5 + 5;
const int INT6 = 1e6 + 6;
const int INT7 = 1e7 + 7;
const int INT8 = 1e8 + 8;
const long long INT9 = 1e9 + 9;
const long long INT12 = 1e12 + 12;
template <class T>
inline T power_fast(T base, T exp, long long md) {
  base %= md;
  T result = 1;
  for (; exp > 0; exp >>= 1) {
    if (exp & 1) result = (result * base) % md;
    base = (base * base) % md;
  }
  return (T)result;
}
template <class T>
inline T power_fast(T base, T exp) {
  T result = 1;
  for (; exp > 0; exp >>= 1) {
    if (exp & 1) result = (result * base);
    base = (base * base);
  }
  return (T)result;
}
template <class T>
inline T power_of_two(T xnxx) {
  return (T)1 << xnxx;
}
template <class T>
inline bool isPowerOfTwo(T x) {
  return x && (!(x & (x - 1)));
}
template <class T>
inline string convert_to_string(T n) {
  stringstream x;
  x << n;
  return x.str();
}
template <class T>
inline T return_randomNum(T min, T max) {
  return min + (rand() % max);
}
template <class T>
inline T random_number_generator(T min, T max) {
  srand((unsigned)time(nullptr));
  return_randomNum(min, max);
}
template <class T>
inline void reduceFraction(T x, T y) {
  T d;
  d = __gcd(x, y);
  x = (x / d);
  y = (y / d);
  cout << x << "/" << y << endl;
}
inline bool isPerfectSquare(long double x) {
  if (x >= 0) {
    long long sr = (x);
    return (sr * sr == x);
  }
  return false;
}
inline bool check_for_substring(string str, string str2) {
  if (str.find(str2) != string::npos) {
    return true;
  } else
    return false;
}
template <class T>
inline void SETARRAY(T *arrr, T arrrsize, T val) {
  for (int i = 0; i < arrrsize; i++) arrr[i] = val;
}
void testCases() {
  fstream file1("output.txt"), file2("realoutput.txt");
  char string1[256], string2[256];
  int j;
  j = 0;
  bool isAccepted = true;
  while (!file1.eof()) {
    file1.getline(string1, 256);
    file2.getline(string2, 256);
    j++;
    if (strcmp(string1, string2) != 0) {
      string fsldkf = " ";
      if (string2 == fsldkf) continue;
      cout << "Test case " << j << " Wrong Answer"
           << "\n";
      cout << "Output:   |" << string1 << "\n";
      cout << "Expected:   |" << string2 << "\n";
      isAccepted = false;
      cout << "\n";
      ;
    }
  }
  if (isAccepted) cout << "Accepted\n";
}
void fileoj(bool file) {}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  fileoj(0);
  int tc = 1;
  while (tc--) {
    int n;
    cin >> n;
    int dollars = 0;
    for (size_t i = 0; i < n; i++) {
      int x;
      cin >> x;
      dollars = max(dollars, x);
    }
    cout << dollars << endl;
  }
  return 0;
  ;
}
