/***************************************
 * Read in a file of the following form:
 * the file begins with a number n, and
 * then has n lines, each containing one
 * number.  Your goal is to keep a running
 * sum where the first number is added, the
 * second subtracted, the third added, the
 * fourth subtracted, and so on.  The file's
 * name is input by the user.
 ***************************************/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main()
{
  // Get file name
  string fname;
  cout << "Filename: ";
  cin >> fname;

  // Open file & read n - we really should check that the file was found!
  ifstream fin(fname.c_str());
  int n;
  fin >> n;
  
  // read and sum values
  int sum = 0, next;
  for(int i = 0; i < n; i++)
  {
    fin >> next;
    sum += (i % 2 == 0 ? next : -next);
  }
  // print result
  cout << sum << endl;

  return 0;
}