/*
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
*/

//mio codiceee
#include<algorithm>
using namespace std;

int tempo_massimo(int N, int a[], int b[]){
  int nulla = 0; //miglior tot se giorno prima fermo
  int sup = 0;  //miglior tot se giorno prima sup
  int hyper = 0;  //miglior tot se giorno prima hyper
  for (int i=0; i<N; i++) { //scorro tutti i giorni
    int migliore = max(nulla,max(sup,hyper));
    //aggiorno
    hyper = b[i] + nulla; //se oggi hyperfast, ieri era fermo
    nulla = migliore; // oggi fermo
    sup = a[i] + migliore; //
  }
    return max(nulla, max(sup,hyper));
}

/*

int main()
{
    int n;
    FILE *in = stdin, *out = stdout;
    assert(fscanf(in, "%d", &n) == 1);

    int *a = (int*)calloc(n, sizeof(int));
    int *b = (int*)calloc(n, sizeof(int));

    for(int i=0; i<n; i++){
      assert(fscanf(in, "%d", a + i) == 1);
      assert(fscanf(in, "%d", b + i) == 1);
    }

    int answ = tempo_massimo(n, a, b);
    fprintf(out, "%d\n", answ);

    free(a);
    free(b);

    fclose(in);
    fclose(out);

    return EXIT_SUCCESS;
}
*/
