#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
  long long int res = 1;
  a %= 1000000007;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
  }
  return res;
}
long long int modInverse(long long int a) { return power(a, 1000000007 - 2); }
const int N = 500023;
bool vis[N];
vector<int> adj[N];
void solve() {
  int n;
  cin >> n;
  int next = 0;
  vector<int> b(n);
  for (long long int i = 0; i < n; i++) cin >> b[i];
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) {
    if (next > b[i]) {
      ans += (next - b[i]);
      next = b[i];
    } else {
      ans += (b[i] - next);
      next = b[i];
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  int t = 0;
  while (t++ < T) {
    solve();
  }
}
