#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n; cin >> n;
  vector<int> a(n+2);
  a[0] = 0;
  a[n+1] = 0;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += abs(a[i] - a[i-1]);
  }
  sum += abs(a[n+1] - a[n]);
  for (int i = 1; i <= n; i++) {
    int diff = abs(a[i+1] - a[i]) + abs(a[i] - a[i-1]) - abs(a[i+1] - a[i-1]);
    cout << sum - diff << endl;
  }
  return 0;
}
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef vector <string> vs;

int main(void){
	map <char, int> m;
	int num[] = {1,5,10,50,100,500,1000};
	for (int i=0; i<7; i++)
		m["IVXLCDM"[i]] = num[i];

	char c;
	string r;
	while (cin>>r){
		int tmp, tmp2= m[r[0]],s=0;
		int n=r.size();
		for (int i=0; i<n; i++){
			tmp = m[r[i]];
			if (tmp2<tmp)
				s-= tmp2*2;
			s += tmp;
			tmp2 = tmp;
		}
		cout<<s<<endl;
	}
}