#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> v(n);
  long long int count = 0;
  long long int front = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> v[i];
    if (i == 0) {
      front = v[i];
      continue;
    }
    if (v[i] > front)
      front = v[i];
    else {
      count += front - v[i];
    }
  }
  cout << front << "\n";
  cout << count;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  { solve(); }
}
