#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define llu unsigned long long
#define inf 99194853094755497
#define pf printf
#define sf scanf
#define sf1(x) scanf("%lld",&x)
#define sf2(x,y) scanf("%lld %lld",&x,&y)
#define sf3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sf4(x,y,z,w) scanf("%lld %lld %lld %lld",&x,&y,&z,&w)
#define pii pair<long long,long long>
#define sq(x) ((x)*(x))
#define MAX 100009
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define PI acos(-1.0)
const double INF = 1e100;
const double EPS = 1e-9;
/*struct debugger
{
    template<typename T> debugger& operator, (const T& v)
    {
        cerr<<v<<" ";
        return *this;
    }
}dbg;
#define deb(args...){dbg, args; cerr<<endl;}*/

template<class T1> void deb(T1 e1)
{
    cout<<e1<<endl;
}
template<class T1,class T2> void deb(T1 e1,T2 e2)
{
    cout<<e1<<" "<<e2<<endl;
}
template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3)
{
    cout<<e1<<" "<<e2<<" "<<e3<<endl;
}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
}
template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
}

template< class T > T gcd(const T a, const T b) { return (b ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(const T a, const T b) { return (a / gcd<T>(a, b) * b); }

///Link List
/*
struct node
{
	int roll;
	node *next, *prev;
};
node *root, *tail;
void append(int roll)
{
	if(root==NULL) ///If the list is empty
	{
		root=new node();
		root->roll=roll;
		root->next=NULL;
		tail=root;
	}
	else
	{
		node *newnode=new node();
		newnode->roll=roll;
		newnode->next=NULL;
		tail->next=newnode; ///add the new node after tail node
		tail=tail->next; ///move tail pointer forward
		///by using tail we can add a new element at O(1) comlexity
	}
}

void delete_node(int roll)
{
	node *current_node=root;
	node *previous_node=NULL;
	while(current_node->roll!=roll) ///Searching node
	{
		previous_node=current_node; ///Save the previous node
		current_node=current_node->next;
	}
	if(current_node==root) ///Delete root
	{
		node *temp=root; ///save root in temporary variable
		root=root->next; ///move root forward
		delete(temp); ///free memory
	}
	else ///delete non-root node
	{
		previous_node->next=current_node->next; ///previous node points the current node's next node
		delete(current_node); ///free current node
	}

}
*/

/*int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
int flip(int N,int pos){return N= N ^ (1<<pos);}
int Least_Significant_Bit(int N){return N= N & (-N);}*/
// moves
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//int dx[]= {0,0,1,-1};/*4 side move*/
//int dy[]= {-1,1,0,0};/*4 side move*/
//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/
//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/
//int dx[]={1,1,2,2,-1,-1,-2,-2};/*night move*/
//int dy[]={2,-2,1,-1,2,-2,1,-1};/*night move*/
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//ios_base::sync_with_stdio(0); cin.tie(0);
struct node{
    ll x,y;
    node(){}
    node(ll x,ll y):x(x),y(y){}
    bool operator < (const node & p) const
    {
        return x<p.x;
    }
};
node a[2900000];
ll ara[2900000];
void update(ll nod,ll b,ll e,ll i,ll val)
{
    if(b==e && b==i){
        a[nod].x++;
        a[nod].y=a[nod].x*val;
        return;
    }
    ll l,mid;
    mid=(b+e)/2;
    l=2*nod;
    if(i<=mid) update(l,b,mid,i,val);
    else update(l+1,mid+1,e,i,val);
    a[nod].y=a[l].y+a[l+1].y;
    a[nod].x=a[l].x+a[l+1].x;
}

node query(ll nod,ll b,ll e,ll i,ll j)
{
    if(i>j) return node(0,0);
    if(b>j || e<i) return node(0,0);
    if(b>=i && e<=j){
        return a[nod];
    }
    ll l,mid;
    mid=(b+e)/2;
    l=2*nod;
    node x=query(l,b,mid,i,j);
    node y=query(l+1,mid+1,e,i,j);
    return node(x.x+y.x,x.y+y.y);
}
vector<ll>v,v1;

int main()
{
    ll i,j,k,x,y,z,t,m,n,l1,l2;
    int l=0;
    sf1(n);
    mem(a,0);
    for(i=1;i<=n;i++){
        sf1(ara[i]);
        x=ara[i]-2;
        y=ara[i]+2;
        v.pb(ara[i]);
        v.pb(x);
        v.pb(y);
    }
    sort(v.begin(),v.end());
    for(i=1;i<v.size();i++){
        if(v[i]!=v[i-1]){
            v1.pb(v[i]);
        }
    }
    v1.pb(v[v.size()-1]);
    v.clear();
    sort(v1.begin(),v1.end());

    long double sum=0;
    for(i=n;i>=1;i--){
        x=upper_bound(v1.begin(),v1.end(),(ara[i]))-v1.begin();
        update(1,1,v1.size(),x,ara[i]);
        node p,q;
        x=upper_bound(v1.begin(),v1.end(),(ara[i]-2))-v1.begin();
        p=query(1,1,v1.size(),1,x);
        x=upper_bound(v1.begin(),v1.end(),(ara[i]+2))-v1.begin();
        q=query(1,1,v1.size(),x,v1.size());
        sum=sum+(long double)((p.y+q.y)-((p.x+q.x)*ara[i]));
    }
    cout<<setprecision(0)<<sum<<'\n';

    return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<list>
#include<queue>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<math.h>
#include<set>
#include<stack>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<iterator>
#include<unordered_map>
using namespace std;
#define ll long long
#define ld long double
#define llu unsigned long long
#define inf 99194853094755497
#define pf printf
#define sf scanf
#define sf1(x) scanf("%lld",&x)
#define sf2(x,y) scanf("%lld %lld",&x,&y)
#define sf3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sf4(x,y,z,w) scanf("%lld %lld %lld %lld",&x,&y,&z,&w)
#define pii pair<long long,long long>
#define sq(x) ((x)*(x))
#define MAX 100009
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define PI acos(-1.0)
const double INF = 1e100;
const double EPS = 1e-9;
/*struct debugger
{
    template<typename T> debugger& operator, (const T& v)
    {
        cerr<<v<<" ";
        return *this;
    }
}dbg;
#define deb(args...){dbg, args; cerr<<endl;}*/

template<class T1> void deb(T1 e1)
{
    cout<<e1<<endl;
}
template<class T1,class T2> void deb(T1 e1,T2 e2)
{
    cout<<e1<<" "<<e2<<endl;
}
template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3)
{
    cout<<e1<<" "<<e2<<" "<<e3<<endl;
}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
}
template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
}

template< class T > T gcd(const T a, const T b) { return (b ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(const T a, const T b) { return (a / gcd<T>(a, b) * b); }

///Link List
/*
struct node
{
	int roll;
	node *next, *prev;
};
node *root, *tail;
void append(int roll)
{
	if(root==NULL) ///If the list is empty
	{
		root=new node();
		root->roll=roll;
		root->next=NULL;
		tail=root;
	}
	else
	{
		node *newnode=new node();
		newnode->roll=roll;
		newnode->next=NULL;
		tail->next=newnode; ///add the new node after tail node
		tail=tail->next; ///move tail pointer forward
		///by using tail we can add a new element at O(1) comlexity
	}
}

void delete_node(int roll)
{
	node *current_node=root;
	node *previous_node=NULL;
	while(current_node->roll!=roll) ///Searching node
	{
		previous_node=current_node; ///Save the previous node
		current_node=current_node->next;
	}
	if(current_node==root) ///Delete root
	{
		node *temp=root; ///save root in temporary variable
		root=root->next; ///move root forward
		delete(temp); ///free memory
	}
	else ///delete non-root node
	{
		previous_node->next=current_node->next; ///previous node points the current node's next node
		delete(current_node); ///free current node
	}

}
*/

/*int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
int flip(int N,int pos){return N= N ^ (1<<pos);}
int Least_Significant_Bit(int N){return N= N & (-N);}*/
// moves
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//int dx[]= {0,0,1,-1};/*4 side move*/
//int dy[]= {-1,1,0,0};/*4 side move*/
//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/
//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/
//int dx[]={1,1,2,2,-1,-1,-2,-2};/*night move*/
//int dy[]={2,-2,1,-1,2,-2,1,-1};/*night move*/
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//ios_base::sync_with_stdio(0); cin.tie(0);
struct node{
    ll x,y;
    node(){}
    node(ll x,ll y):x(x),y(y){}
    bool operator < (const node & p) const
    {
        return x<p.x;
    }
};
node a[1000000];
map<int,int>mp;
ll ara[1000000];
void update(ll nod,ll b,ll e,ll i,ll val)
{
    if(b==e && b==i){
        a[nod].x++;
        a[nod].y=a[nod].x*val;
        return;
    }
    ll l,mid;
    mid=(b+e)/2;
    l=2*nod;
    if(i<=mid) update(l,b,mid,i,val);
    else update(l+1,mid+1,e,i,val);
    a[nod].y=a[l].y+a[l+1].y;
    a[nod].x=a[l].x+a[l+1].x;
}

node query(ll nod,ll b,ll e,ll i,ll j)
{
    if(i>j) return node(0,0);
    if(b>j || e<i) return node(0,0);
    if(b>=i && e<=j){
        return a[nod];
    }
    ll l,mid;
    mid=(b+e)/2;
    l=2*nod;
    node x=query(l,b,mid,i,j);
    node y=query(l+1,mid+1,e,i,j);
    return node(x.x+y.x,x.y+y.y);
}
vector<ll>v,v1;

int main()
{
    ll i,j,k,x,y,z,t,m,n,l1,l2;
    int l=0;
    sf1(n);
    mem(a,0);
    for(i=1;i<=n;i++){
        sf1(ara[i]);
        x=ara[i]-2;
        y=ara[i]+2;
        v.pb(ara[i]);
        v.pb(x);
        v.pb(y);
    }
    sort(v.begin(),v.end());
    for(i=0;i<v.size();i++){
        if(mp.count((int)v[i])==0){
            x=(int) v[i];
            mp[x]=++l;
        }
    }
    ll sum=0;
    for(i=n;i>=1;i--){
        update(1,1,n,(ll)mp[ara[i]],ara[i]);
        node p,q;
        p=query(1,1,n,1,(ll)mp[ara[i]-2]);
        q=query(1,1,n,(ll)mp[ara[i]+2],(ll)l);
        sum=sum+(p.y+q.y)-((p.x+q.x)*ara[i]);
    }
    deb(sum);

    return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<list>
#include<queue>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<math.h>
#include<set>
#include<stack>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<iterator>
#include<unordered_map>
using namespace std;
#define ll long long
#define ld long double
#define llu unsigned long long
#define inf 99194853094755497
#define pf printf
#define sf scanf
#define sf1(x) scanf("%lld",&x)
#define sf2(x,y) scanf("%lld %lld",&x,&y)
#define sf3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sf4(x,y,z,w) scanf("%lld %lld %lld %lld",&x,&y,&z,&w)
#define pii pair<long long,long long>
#define sq(x) ((x)*(x))
#define MAX 100009
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define PI acos(-1.0)
const double INF = 1e100;
const double EPS = 1e-9;
/*struct debugger
{
    template<typename T> debugger& operator, (const T& v)
    {
        cerr<<v<<" ";
        return *this;
    }
}dbg;
#define deb(args...){dbg, args; cerr<<endl;}*/

template<class T1> void deb(T1 e1)
{
    cout<<e1<<endl;
}
template<class T1,class T2> void deb(T1 e1,T2 e2)
{
    cout<<e1<<" "<<e2<<endl;
}
template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3)
{
    cout<<e1<<" "<<e2<<" "<<e3<<endl;
}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
}
template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
}

template< class T > T gcd(const T a, const T b) { return (b ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(const T a, const T b) { return (a / gcd<T>(a, b) * b); }

///Link List
/*
struct node
{
	int roll;
	node *next, *prev;
};
node *root, *tail;
void append(int roll)
{
	if(root==NULL) ///If the list is empty
	{
		root=new node();
		root->roll=roll;
		root->next=NULL;
		tail=root;
	}
	else
	{
		node *newnode=new node();
		newnode->roll=roll;
		newnode->next=NULL;
		tail->next=newnode; ///add the new node after tail node
		tail=tail->next; ///move tail pointer forward
		///by using tail we can add a new element at O(1) comlexity
	}
}

void delete_node(int roll)
{
	node *current_node=root;
	node *previous_node=NULL;
	while(current_node->roll!=roll) ///Searching node
	{
		previous_node=current_node; ///Save the previous node
		current_node=current_node->next;
	}
	if(current_node==root) ///Delete root
	{
		node *temp=root; ///save root in temporary variable
		root=root->next; ///move root forward
		delete(temp); ///free memory
	}
	else ///delete non-root node
	{
		previous_node->next=current_node->next; ///previous node points the current node's next node
		delete(current_node); ///free current node
	}

}
*/

/*int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
int flip(int N,int pos){return N= N ^ (1<<pos);}
int Least_Significant_Bit(int N){return N= N & (-N);}*/
// moves
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//int dx[]= {0,0,1,-1};/*4 side move*/
//int dy[]= {-1,1,0,0};/*4 side move*/
//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/
//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/
//int dx[]={1,1,2,2,-1,-1,-2,-2};/*night move*/
//int dy[]={2,-2,1,-1,2,-2,1,-1};/*night move*/
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//ios_base::sync_with_stdio(0); cin.tie(0);
struct node{
    ll x,y;
    node(){}
    node(ll x,ll y):x(x),y(y){}
    bool operator < (const node & p) const
    {
        return x<p.x;
    }
};
node a[1000000];
ll ara[1000000];
void update(ll nod,ll b,ll e,ll i,ll val)
{
    if(b==e && b==i){
        a[nod].x++;
        a[nod].y=a[nod].x*val;
        return;
    }
    ll l,mid;
    mid=(b+e)/2;
    l=2*nod;
    if(i<=mid) update(l,b,mid,i,val);
    else update(l+1,mid+1,e,i,val);
    a[nod].y=a[l].y+a[l+1].y;
    a[nod].x=a[l].x+a[l+1].x;
}

node query(ll nod,ll b,ll e,ll i,ll j)
{
    if(i>j) return node(0,0);
    if(b>j || e<i) return node(0,0);
    if(b>=i && e<=j){
        return a[nod];
    }
    ll l,mid;
    mid=(b+e)/2;
    l=2*nod;
    node x=query(l,b,mid,i,j);
    node y=query(l+1,mid+1,e,i,j);
    return node(x.x+y.x,x.y+y.y);
}
vector<ll>v,v1;

int main()
{
    ll i,j,k,x,y,z,t,m,n,l1,l2;
    int l=0;
    sf1(n);
    mem(a,0);
    for(i=1;i<=n;i++){
        sf1(ara[i]);
        x=ara[i]-2;
        y=ara[i]+2;
        v.pb(ara[i]);
        v.pb(x);
        v.pb(y);
    }
    sort(v.begin(),v.end());
    for(i=1;i<v.size();i++){
        if(v[i]!=v[i-1]){
            v1.pb(v[i]);
        }
    }
    v1.pb(v[v.size()-1]);
    v.clear();
    sort(v1.begin(),v1.end());

    ll sum=0;
    for(i=n;i>=1;i--){
        x=upper_bound(v1.begin(),v1.end(),(ara[i]))-v1.begin();
        update(1,1,v1.size(),x,ara[i]);
        node p,q;
        x=upper_bound(v1.begin(),v1.end(),(ara[i]-2))-v1.begin();
        p=query(1,1,v1.size(),1,x);
        x=upper_bound(v1.begin(),v1.end(),(ara[i]+2))-v1.begin();
        q=query(1,1,v1.size(),x,v1.size());
        sum=sum+(p.y+q.y)-((p.x+q.x)*ara[i]);
    }
    deb(sum);

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define llu unsigned long long
#define inf 99194853094755497
#define pf printf
#define sf scanf
#define sf1(x) scanf("%lld",&x)
#define sf2(x,y) scanf("%lld %lld",&x,&y)
#define sf3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sf4(x,y,z,w) scanf("%lld %lld %lld %lld",&x,&y,&z,&w)
#define pii pair<long long,long long>
#define sq(x) ((x)*(x))
#define MAX 100009
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define PI acos(-1.0)
const double INF = 1e100;
const double EPS = 1e-9;
/*struct debugger
{
    template<typename T> debugger& operator, (const T& v)
    {
        cerr<<v<<" ";
        return *this;
    }
}dbg;
#define deb(args...){dbg, args; cerr<<endl;}*/

template<class T1> void deb(T1 e1)
{
    cout<<e1<<endl;
}
template<class T1,class T2> void deb(T1 e1,T2 e2)
{
    cout<<e1<<" "<<e2<<endl;
}
template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3)
{
    cout<<e1<<" "<<e2<<" "<<e3<<endl;
}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
}
template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
}

template< class T > T gcd(const T a, const T b) { return (b ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(const T a, const T b) { return (a / gcd<T>(a, b) * b); }

///Link List
/*
struct node
{
	int roll;
	node *next, *prev;
};
node *root, *tail;
void append(int roll)
{
	if(root==NULL) ///If the list is empty
	{
		root=new node();
		root->roll=roll;
		root->next=NULL;
		tail=root;
	}
	else
	{
		node *newnode=new node();
		newnode->roll=roll;
		newnode->next=NULL;
		tail->next=newnode; ///add the new node after tail node
		tail=tail->next; ///move tail pointer forward
		///by using tail we can add a new element at O(1) comlexity
	}
}

void delete_node(int roll)
{
	node *current_node=root;
	node *previous_node=NULL;
	while(current_node->roll!=roll) ///Searching node
	{
		previous_node=current_node; ///Save the previous node
		current_node=current_node->next;
	}
	if(current_node==root) ///Delete root
	{
		node *temp=root; ///save root in temporary variable
		root=root->next; ///move root forward
		delete(temp); ///free memory
	}
	else ///delete non-root node
	{
		previous_node->next=current_node->next; ///previous node points the current node's next node
		delete(current_node); ///free current node
	}

}
*/

/*int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
int flip(int N,int pos){return N= N ^ (1<<pos);}
int Least_Significant_Bit(int N){return N= N & (-N);}*/
// moves
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//int dx[]= {0,0,1,-1};/*4 side move*/
//int dy[]= {-1,1,0,0};/*4 side move*/
//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/
//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/
//int dx[]={1,1,2,2,-1,-1,-2,-2};/*night move*/
//int dy[]={2,-2,1,-1,2,-2,1,-1};/*night move*/
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//ios_base::sync_with_stdio(0); cin.tie(0);
struct node{
    ll x,y;
    node(){}
    node(ll x,ll y):x(x),y(y){}
    bool operator < (const node & p) const
    {
        return x<p.x;
    }
};
node a[2900000];
ll ara[2900000];
void update(ll nod,ll b,ll e,ll i,ll val)
{
    if(b==e && b==i){
        a[nod].x++;
        a[nod].y=a[nod].x*val;
        return;
    }
    ll l,mid;
    mid=(b+e)/2;
    l=2*nod;
    if(i<=mid) update(l,b,mid,i,val);
    else update(l+1,mid+1,e,i,val);
    a[nod].y=a[l].y+a[l+1].y;
    a[nod].x=a[l].x+a[l+1].x;
}

node query(ll nod,ll b,ll e,ll i,ll j)
{
    if(i>j) return node(0,0);
    if(b>j || e<i) return node(0,0);
    if(b>=i && e<=j){
        return a[nod];
    }
    ll l,mid;
    mid=(b+e)/2;
    l=2*nod;
    node x=query(l,b,mid,i,j);
    node y=query(l+1,mid+1,e,i,j);
    return node(x.x+y.x,x.y+y.y);
}
vector<ll>v,v1;

int main()
{
    ll i,j,k,x,y,z,t,m,n,l1,l2;
    int l=0;
    sf1(n);
    mem(a,0);
    for(i=1;i<=n;i++){
        sf1(ara[i]);
        x=ara[i]-2;
        y=ara[i]+2;
        v.pb(ara[i]);
        v.pb(x);
        v.pb(y);
    }
    sort(v.begin(),v.end());
    for(i=1;i<v.size();i++){
        if(v[i]!=v[i-1]){
            v1.pb(v[i]);
        }
    }
    v1.pb(v[v.size()-1]);
    v.clear();
    sort(v1.begin(),v1.end());

    long double sum=0;
    for(i=n;i>=1;i--){
        x=upper_bound(v1.begin(),v1.end(),(ara[i]))-v1.begin();
        update(1,1,v1.size(),x,ara[i]);
        node p,q;
        x=upper_bound(v1.begin(),v1.end(),(ara[i]-2))-v1.begin();
        p=query(1,1,v1.size(),1,x);
        x=upper_bound(v1.begin(),v1.end(),(ara[i]+2))-v1.begin();
        q=query(1,1,v1.size(),x,v1.size());
        sum=sum+(long double)((p.y+q.y)-((p.x+q.x)*ara[i]));
    }
    cout<<fixed<<setprecision(0)<<sum<<'\n';

    return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<list>
#include<queue>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<math.h>
#include<set>
#include<stack>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<iterator>
#include<unordered_map>
using namespace std;
#define ll long long
#define ld long double
#define llu unsigned long long
#define inf 99194853094755497
#define pf printf
#define sf scanf
#define sf1(x) scanf("%lld",&x)
#define sf2(x,y) scanf("%lld %lld",&x,&y)
#define sf3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sf4(x,y,z,w) scanf("%lld %lld %lld %lld",&x,&y,&z,&w)
#define pii pair<long long,long long>
#define sq(x) ((x)*(x))
#define MAX 100009
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define PI acos(-1.0)
const double INF = 1e100;
const double EPS = 1e-9;
/*struct debugger
{
    template<typename T> debugger& operator, (const T& v)
    {
        cerr<<v<<" ";
        return *this;
    }
}dbg;
#define deb(args...){dbg, args; cerr<<endl;}*/

template<class T1> void deb(T1 e1)
{
    cout<<e1<<endl;
}
template<class T1,class T2> void deb(T1 e1,T2 e2)
{
    cout<<e1<<" "<<e2<<endl;
}
template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3)
{
    cout<<e1<<" "<<e2<<" "<<e3<<endl;
}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
}
template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
}

template< class T > T gcd(const T a, const T b) { return (b ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(const T a, const T b) { return (a / gcd<T>(a, b) * b); }

///Link List
/*
struct node
{
	int roll;
	node *next, *prev;
};
node *root, *tail;
void append(int roll)
{
	if(root==NULL) ///If the list is empty
	{
		root=new node();
		root->roll=roll;
		root->next=NULL;
		tail=root;
	}
	else
	{
		node *newnode=new node();
		newnode->roll=roll;
		newnode->next=NULL;
		tail->next=newnode; ///add the new node after tail node
		tail=tail->next; ///move tail pointer forward
		///by using tail we can add a new element at O(1) comlexity
	}
}

void delete_node(int roll)
{
	node *current_node=root;
	node *previous_node=NULL;
	while(current_node->roll!=roll) ///Searching node
	{
		previous_node=current_node; ///Save the previous node
		current_node=current_node->next;
	}
	if(current_node==root) ///Delete root
	{
		node *temp=root; ///save root in temporary variable
		root=root->next; ///move root forward
		delete(temp); ///free memory
	}
	else ///delete non-root node
	{
		previous_node->next=current_node->next; ///previous node points the current node's next node
		delete(current_node); ///free current node
	}

}
*/

/*int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
int flip(int N,int pos){return N= N ^ (1<<pos);}
int Least_Significant_Bit(int N){return N= N & (-N);}*/
// moves
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//int dx[]= {0,0,1,-1};/*4 side move*/
//int dy[]= {-1,1,0,0};/*4 side move*/
//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/
//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/
//int dx[]={1,1,2,2,-1,-1,-2,-2};/*night move*/
//int dy[]={2,-2,1,-1,2,-2,1,-1};/*night move*/
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//ios_base::sync_with_stdio(0); cin.tie(0);
struct node{
    ll x,y;
    node(){}
    node(ll x,ll y):x(x),y(y){}
    bool operator < (const node & p) const
    {
        return x<p.x;
    }
};
node a[1000000];
set<ll>s;
ll ara[1000000];
void update(ll nod,ll b,ll e,ll i,ll val)
{
    if(b==e && b==i){
        a[nod].x++;
        a[nod].y=a[nod].x*val;
        return;
    }
    ll l,mid;
    mid=(b+e)/2;
    l=2*nod;
    if(i<=mid) update(l,b,mid,i,val);
    else update(l+1,mid+1,e,i,val);
    a[nod].y=a[l].y+a[l+1].y;
    a[nod].x=a[l].x+a[l+1].x;
}

node query(ll nod,ll b,ll e,ll i,ll j)
{
    if(i>j) return node(0,0);
    if(b>j || e<i) return node(0,0);
    if(b>=i && e<=j){
        return a[nod];
    }
    ll l,mid;
    mid=(b+e)/2;
    l=2*nod;
    node x=query(l,b,mid,i,j);
    node y=query(l+1,mid+1,e,i,j);
    return node(x.x+y.x,x.y+y.y);
}
vector<ll>v,v1;

int main()
{
    ll i,j,k,x,y,z,t,m,n,l1,l2;
    int l=0;
    sf1(n);
    mem(a,0);
    for(i=1;i<=n;i++){
        sf1(ara[i]);
        x=ara[i]-2;
        y=ara[i]+2;
        v.pb(ara[i]);
        v.pb(x);
        v.pb(y);
    }
    sort(v.begin(),v.end());
    for(i=1;i<v.size();i++){
        if(v[i]!=v[i-1]){
            v1.pb(v[i]);
        }
    }
    v1.pb(v[v.size()-1]);
    sort(v1.begin(),v1.end());

    ll sum=0;
    for(i=n;i>=1;i--){
        x=upper_bound(v1.begin(),v1.end(),(ara[i]))-v1.begin();
        update(1,1,n,x,ara[i]);
        node p,q;
        x=upper_bound(v1.begin(),v1.end(),(ara[i]-2))-v1.begin();
        p=query(1,1,n,1,x);
        x=upper_bound(v1.begin(),v1.end(),(ara[i]+2))-v1.begin();
        q=query(1,1,n,x,v1.size());
        sum=sum+(p.y+q.y)-((p.x+q.x)*ara[i]);
    }
    deb(sum);

    return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<list>
#include<queue>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<math.h>
#include<set>
#include<stack>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<iterator>
#include<unordered_map>
using namespace std;
#define ll long long
#define ld long double
#define llu unsigned long long
#define inf 99194853094755497
#define pf printf
#define sf scanf
#define sf1(x) scanf("%lld",&x)
#define sf2(x,y) scanf("%lld %lld",&x,&y)
#define sf3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sf4(x,y,z,w) scanf("%lld %lld %lld %lld",&x,&y,&z,&w)
#define pii pair<long long,long long>
#define sq(x) ((x)*(x))
#define MAX 100009
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define PI acos(-1.0)
const double INF = 1e100;
const double EPS = 1e-9;
/*struct debugger
{
    template<typename T> debugger& operator, (const T& v)
    {
        cerr<<v<<" ";
        return *this;
    }
}dbg;
#define deb(args...){dbg, args; cerr<<endl;}*/

template<class T1> void deb(T1 e1)
{
    cout<<e1<<endl;
}
template<class T1,class T2> void deb(T1 e1,T2 e2)
{
    cout<<e1<<" "<<e2<<endl;
}
template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3)
{
    cout<<e1<<" "<<e2<<" "<<e3<<endl;
}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
}
template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
}

template< class T > T gcd(const T a, const T b) { return (b ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(const T a, const T b) { return (a / gcd<T>(a, b) * b); }

///Link List
/*
struct node
{
	int roll;
	node *next, *prev;
};
node *root, *tail;
void append(int roll)
{
	if(root==NULL) ///If the list is empty
	{
		root=new node();
		root->roll=roll;
		root->next=NULL;
		tail=root;
	}
	else
	{
		node *newnode=new node();
		newnode->roll=roll;
		newnode->next=NULL;
		tail->next=newnode; ///add the new node after tail node
		tail=tail->next; ///move tail pointer forward
		///by using tail we can add a new element at O(1) comlexity
	}
}

void delete_node(int roll)
{
	node *current_node=root;
	node *previous_node=NULL;
	while(current_node->roll!=roll) ///Searching node
	{
		previous_node=current_node; ///Save the previous node
		current_node=current_node->next;
	}
	if(current_node==root) ///Delete root
	{
		node *temp=root; ///save root in temporary variable
		root=root->next; ///move root forward
		delete(temp); ///free memory
	}
	else ///delete non-root node
	{
		previous_node->next=current_node->next; ///previous node points the current node's next node
		delete(current_node); ///free current node
	}

}
*/

/*int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
int flip(int N,int pos){return N= N ^ (1<<pos);}
int Least_Significant_Bit(int N){return N= N & (-N);}*/
// moves
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//int dx[]= {0,0,1,-1};/*4 side move*/
//int dy[]= {-1,1,0,0};/*4 side move*/
//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/
//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/
//int dx[]={1,1,2,2,-1,-1,-2,-2};/*night move*/
//int dy[]={2,-2,1,-1,2,-2,1,-1};/*night move*/
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//ios_base::sync_with_stdio(0); cin.tie(0);
struct node{
    ll x,y;
    node(){}
    node(ll x,ll y):x(x),y(y){}
    bool operator < (const node & p) const
    {
        return x<p.x;
    }
};
node a[1000000];
unordered_map<ll,ll>mp;
ll ara[1000000];
void update(ll nod,ll b,ll e,ll i,ll val)
{
    if(b==e && b==i){
        a[nod].x++;
        a[nod].y=a[nod].x*val;
        return;
    }
    ll l,mid;
    mid=(b+e)/2;
    l=2*nod;
    if(i<=mid) update(l,b,mid,i,val);
    else update(l+1,mid+1,e,i,val);
    a[nod].y=a[l].y+a[l+1].y;
    a[nod].x=a[l].x+a[l+1].x;
}

node query(ll nod,ll b,ll e,ll i,ll j)
{
    if(i>j) return node(0,0);
    if(b>j || e<i) return node(0,0);
    if(b>=i && e<=j){
        return a[nod];
    }
    ll l,mid;
    mid=(b+e)/2;
    l=2*nod;
    node x=query(l,b,mid,i,j);
    node y=query(l+1,mid+1,e,i,j);
    return node(x.x+y.x,x.y+y.y);
}
vector<ll>v;

int main()
{
    ll i,j,k,l=0,x,y,z,t,m,n,l1,l2;
    sf1(n);
    mem(a,0);
    for(i=1;i<=n;i++){
        sf1(ara[i]);
        x=ara[i]-2;
        y=ara[i]+2;
        v.pb(ara[i]);
        v.pb(x);
        v.pb(y);
    }
    sort(v.begin(),v.end());
    for(i=0;i<v.size();i++){
        if(!mp[v[i]]){
            mp[v[i]]=++l;
        }
    }
    ll sum=0;
    for(i=n;i>=1;i--){
        update(1,1,n,mp[ara[i]],ara[i]);
        node p,q;
        p=query(1,1,n,1,mp[ara[i]-2]);
        q=query(1,1,n,mp[ara[i]+2],l);
        sum=sum+(p.y+q.y)-((p.x+q.x)*ara[i]);
    }
    deb(sum);

    return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<list>
#include<queue>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<math.h>
#include<set>
#include<stack>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<iterator>
#include<unordered_map>
using namespace std;
#define ll long long
#define ld long double
#define llu unsigned long long
#define inf 99194853094755497
#define pf printf
#define sf scanf
#define sf1(x) scanf("%lld",&x)
#define sf2(x,y) scanf("%lld %lld",&x,&y)
#define sf3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sf4(x,y,z,w) scanf("%lld %lld %lld %lld",&x,&y,&z,&w)
#define pii pair<long long,long long>
#define sq(x) ((x)*(x))
#define MAX 100009
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define PI acos(-1.0)
const double INF = 1e100;
const double EPS = 1e-9;
/*struct debugger
{
    template<typename T> debugger& operator, (const T& v)
    {
        cerr<<v<<" ";
        return *this;
    }
}dbg;
#define deb(args...){dbg, args; cerr<<endl;}*/

template<class T1> void deb(T1 e1)
{
    cout<<e1<<endl;
}
template<class T1,class T2> void deb(T1 e1,T2 e2)
{
    cout<<e1<<" "<<e2<<endl;
}
template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3)
{
    cout<<e1<<" "<<e2<<" "<<e3<<endl;
}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
}
template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
}

template< class T > T gcd(const T a, const T b) { return (b ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(const T a, const T b) { return (a / gcd<T>(a, b) * b); }

///Link List
/*
struct node
{
	int roll;
	node *next, *prev;
};
node *root, *tail;
void append(int roll)
{
	if(root==NULL) ///If the list is empty
	{
		root=new node();
		root->roll=roll;
		root->next=NULL;
		tail=root;
	}
	else
	{
		node *newnode=new node();
		newnode->roll=roll;
		newnode->next=NULL;
		tail->next=newnode; ///add the new node after tail node
		tail=tail->next; ///move tail pointer forward
		///by using tail we can add a new element at O(1) comlexity
	}
}

void delete_node(int roll)
{
	node *current_node=root;
	node *previous_node=NULL;
	while(current_node->roll!=roll) ///Searching node
	{
		previous_node=current_node; ///Save the previous node
		current_node=current_node->next;
	}
	if(current_node==root) ///Delete root
	{
		node *temp=root; ///save root in temporary variable
		root=root->next; ///move root forward
		delete(temp); ///free memory
	}
	else ///delete non-root node
	{
		previous_node->next=current_node->next; ///previous node points the current node's next node
		delete(current_node); ///free current node
	}

}
*/

/*int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
int flip(int N,int pos){return N= N ^ (1<<pos);}
int Least_Significant_Bit(int N){return N= N & (-N);}*/
// moves
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//int dx[]= {0,0,1,-1};/*4 side move*/
//int dy[]= {-1,1,0,0};/*4 side move*/
//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/
//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/
//int dx[]={1,1,2,2,-1,-1,-2,-2};/*night move*/
//int dy[]={2,-2,1,-1,2,-2,1,-1};/*night move*/
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//ios_base::sync_with_stdio(0); cin.tie(0);
struct node{
    ll x,y;
    node(){}
    node(ll x,ll y):x(x),y(y){}
    bool operator < (const node & p) const
    {
        return x<p.x;
    }
};
node a[2900000];
ll ara[2900000];
void update(ll nod,ll b,ll e,ll i,ll val)
{
    if(b==e && b==i){
        a[nod].x++;
        a[nod].y=a[nod].x*val;
        return;
    }
    ll l,mid;
    mid=(b+e)/2;
    l=2*nod;
    if(i<=mid) update(l,b,mid,i,val);
    else update(l+1,mid+1,e,i,val);
    a[nod].y=a[l].y+a[l+1].y;
    a[nod].x=a[l].x+a[l+1].x;
}

node query(ll nod,ll b,ll e,ll i,ll j)
{
    if(i>j) return node(0,0);
    if(b>j || e<i) return node(0,0);
    if(b>=i && e<=j){
        return a[nod];
    }
    ll l,mid;
    mid=(b+e)/2;
    l=2*nod;
    node x=query(l,b,mid,i,j);
    node y=query(l+1,mid+1,e,i,j);
    return node(x.x+y.x,x.y+y.y);
}
vector<ll>v,v1;

int main()
{
    ll i,j,k,x,y,z,t,m,n,l1,l2;
    int l=0;
    sf1(n);
    mem(a,0);
    for(i=1;i<=n;i++){
        sf1(ara[i]);
        x=ara[i]-2;
        y=ara[i]+2;
        v.pb(ara[i]);
        v.pb(x);
        v.pb(y);
    }
    sort(v.begin(),v.end());
    for(i=1;i<v.size();i++){
        if(v[i]!=v[i-1]){
            v1.pb(v[i]);
        }
    }
    v1.pb(v[v.size()-1]);
    v.clear();
    sort(v1.begin(),v1.end());

    ll sum=0;
    for(i=n;i>=1;i--){
        x=upper_bound(v1.begin(),v1.end(),(ara[i]))-v1.begin();
        update(1,1,v1.size(),x,ara[i]);
        node p,q;
        x=upper_bound(v1.begin(),v1.end(),(ara[i]-2))-v1.begin();
        p=query(1,1,v1.size(),1,x);
        x=upper_bound(v1.begin(),v1.end(),(ara[i]+2))-v1.begin();
        q=query(1,1,v1.size(),x,v1.size());
        sum=sum+(p.y+q.y)-((p.x+q.x)*ara[i]);
    }
    deb(sum);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" is "<<(x)<<'\n'

#define li long long int

#define all(v) v.begin(), v.end()
const int maxn = 2e5+10;

vector<int> tree[4*maxn];

int arr[maxn];

li cum[maxn];

int cnt = 0;
li sum = 0;

void build(int node, int l, int r) {

	if(l == r) {

		tree[node].push_back(arr[l]);

		return;

	}

	int mid = l + r >> 1,

	left = node << 1, right = left|1;

	build(left, l, mid);

	build(right, mid+1, r);

	merge(all(tree[left]), all(tree[right]),

	        back_inserter(tree[node]));

}

int query(int node, int l, int r, int i, int j, int k) {

	if(i > r || l > j) return 0;

	if(i <= l && r <= j) {

		return upper_bound(all(tree[node]), k) - lower_bound(all(tree[node]), k);

	}

	int mid = l + r >> 1,

		left = node << 1, right = left|1;

	return query(left, l, mid, i, j, k) +

		   query(right, mid+1, r, i, j, k);

}

int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin>>n;

	for(int i=1;i<=n;i++) cin>>arr[i];

	for(int i=1;i<=n;i++)
	{
		cum[i]=cum[i-1]+arr[i];
	}

	build(1,1,n);

	li ans = 0;

	for(int i=1;i<=n-1;i++)
	{

         //debug(i);

        int x1 =  query(1,1,n,i+1,n,arr[i]-1);
        int x2 =  query(1,1,n,i+1,n,arr[i]);
        int x3 =  query(1,1,n,i+1,n,arr[i]+1);

        /*debug(i);

       debug(x1);
       debug(x2);
       debug(x3);*/

        li tm = (cum[n]-cum[i]);

       // debug(tm);

        tm-=(x1*1ll*(arr[i]-1));
       // debug(tm);

        tm-=(x2*1ll*(arr[i]));
        //debug(tm);

        tm-=(x3*1ll*(arr[i]+1));
        //debug(tm);

        tm-=1ll*(n-i-(x1+x2+x3))*arr[i];

        ans+=tm;

	}
	cout<<ans<<'\n';

	return 0;
}

/*
*/


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x, y, z, n, m, p, q, r, sum, ans;

ll ara[400000];

map < ll, ll > cnt, sums;

int main()
{
    cin >> n;
    for(ll i = 1; i <= n; i++){
        scanf("%lld", &ara[i]);
        cnt[ara[i]]++;
        sum += ara[i];
    }

    for(ll i = 1; i <= n; i++){

        sum -= cnt[ara[i]] * ara[i];
        sum -= cnt[ara[i] + 1] * (ara[i] + 1);
        sum -= cnt[ara[i] - 1] * (ara[i] - 1);

        ll tmp = n - i + 1;
        tmp -= cnt[ara[i]];
        tmp -= cnt[ara[i] + 1];
        tmp -= cnt[ara[i] - 1];

//        cout << i << ' ' << ara[i] << ' ' << tmp << ' ' << sum << endl;

        ans += sum - tmp * ara[i];

        sum += cnt[ara[i]] * ara[i];
        sum += cnt[ara[i] + 1] * (ara[i] + 1);
        sum += cnt[ara[i] - 1] * (ara[i] - 1);

        sum -= ara[i];
        cnt[ara[i]]--;
    }

    cout << ans << endl;

    return 0;
}

/*

*/


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<list>
#include<queue>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<math.h>
#include<set>
#include<stack>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<iterator>
#include<unordered_map>
using namespace std;
#define ll long long
#define ld long double
#define llu unsigned long long
#define inf 99194853094755497
#define pf printf
#define sf scanf
#define sf1(x) scanf("%lld",&x)
#define sf2(x,y) scanf("%lld %lld",&x,&y)
#define sf3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sf4(x,y,z,w) scanf("%lld %lld %lld %lld",&x,&y,&z,&w)
#define pii pair<long long,long long>
#define sq(x) ((x)*(x))
#define MAX 100009
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define PI acos(-1.0)
const double INF = 1e100;
const double EPS = 1e-9;
/*struct debugger
{
    template<typename T> debugger& operator, (const T& v)
    {
        cerr<<v<<" ";
        return *this;
    }
}dbg;
#define deb(args...){dbg, args; cerr<<endl;}*/

template<class T1> void deb(T1 e1)
{
    cout<<e1<<endl;
}
template<class T1,class T2> void deb(T1 e1,T2 e2)
{
    cout<<e1<<" "<<e2<<endl;
}
template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3)
{
    cout<<e1<<" "<<e2<<" "<<e3<<endl;
}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
}
template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
}

template< class T > T gcd(const T a, const T b) { return (b ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(const T a, const T b) { return (a / gcd<T>(a, b) * b); }

///Link List
/*
struct node
{
	int roll;
	node *next, *prev;
};
node *root, *tail;
void append(int roll)
{
	if(root==NULL) ///If the list is empty
	{
		root=new node();
		root->roll=roll;
		root->next=NULL;
		tail=root;
	}
	else
	{
		node *newnode=new node();
		newnode->roll=roll;
		newnode->next=NULL;
		tail->next=newnode; ///add the new node after tail node
		tail=tail->next; ///move tail pointer forward
		///by using tail we can add a new element at O(1) comlexity
	}
}

void delete_node(int roll)
{
	node *current_node=root;
	node *previous_node=NULL;
	while(current_node->roll!=roll) ///Searching node
	{
		previous_node=current_node; ///Save the previous node
		current_node=current_node->next;
	}
	if(current_node==root) ///Delete root
	{
		node *temp=root; ///save root in temporary variable
		root=root->next; ///move root forward
		delete(temp); ///free memory
	}
	else ///delete non-root node
	{
		previous_node->next=current_node->next; ///previous node points the current node's next node
		delete(current_node); ///free current node
	}

}
*/

/*int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
int flip(int N,int pos){return N= N ^ (1<<pos);}
int Least_Significant_Bit(int N){return N= N & (-N);}*/
// moves
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//int dx[]= {0,0,1,-1};/*4 side move*/
//int dy[]= {-1,1,0,0};/*4 side move*/
//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/
//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/
//int dx[]={1,1,2,2,-1,-1,-2,-2};/*night move*/
//int dy[]={2,-2,1,-1,2,-2,1,-1};/*night move*/
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//ios_base::sync_with_stdio(0); cin.tie(0);
struct node{
    ll x,y;
    node(){}
    node(ll x,ll y):x(x),y(y){}
    bool operator < (const node & p) const
    {
        return x<p.x;
    }
};
node a[1900000];
ll ara[1900000];
void update(ll nod,ll b,ll e,ll i,ll val)
{
    if(b==e && b==i){
        a[nod].x++;
        a[nod].y=a[nod].x*val;
        return;
    }
    ll l,mid;
    mid=(b+e)/2;
    l=2*nod;
    if(i<=mid) update(l,b,mid,i,val);
    else update(l+1,mid+1,e,i,val);
    a[nod].y=a[l].y+a[l+1].y;
    a[nod].x=a[l].x+a[l+1].x;
}

node query(ll nod,ll b,ll e,ll i,ll j)
{
    if(i>j) return node(0,0);
    if(b>j || e<i) return node(0,0);
    if(b>=i && e<=j){
        return a[nod];
    }
    ll l,mid;
    mid=(b+e)/2;
    l=2*nod;
    node x=query(l,b,mid,i,j);
    node y=query(l+1,mid+1,e,i,j);
    return node(x.x+y.x,x.y+y.y);
}
vector<ll>v,v1;

int main()
{
    ll i,j,k,x,y,z,t,m,n,l1,l2;
    int l=0;
    sf1(n);
    mem(a,0);
    for(i=1;i<=n;i++){
        sf1(ara[i]);
        x=ara[i]-2;
        y=ara[i]+2;
        v.pb(ara[i]);
        v.pb(x);
        v.pb(y);
    }
    sort(v.begin(),v.end());
    for(i=1;i<v.size();i++){
        if(v[i]!=v[i-1]){
            v1.pb(v[i]);
        }
    }
    v1.pb(v[v.size()-1]);
    v.clear();
    sort(v1.begin(),v1.end());

    ll sum=0;
    for(i=n;i>=1;i--){
        x=upper_bound(v1.begin(),v1.end(),(ara[i]))-v1.begin();
        update(1,1,v1.size(),x,ara[i]);
        node p,q;
        x=upper_bound(v1.begin(),v1.end(),(ara[i]-2))-v1.begin();
        p=query(1,1,v1.size(),1,x);
        x=upper_bound(v1.begin(),v1.end(),(ara[i]+2))-v1.begin();
        q=query(1,1,v1.size(),x,v1.size());
        sum=sum+(p.y+q.y)-((p.x+q.x)*ara[i]);
    }
    deb(sum);

    return 0;
}


#include <bits/stdc++.h>
#define ill int long long
#define ld long double
#define pb push_back
#define se second
#define fi first
using namespace std;
int n,a[200005],i,j,k,c[200005];
ill sum=0,c1[200005];
map <int,int>d;
set<int>b;
pair <ill,ill>t[800005],x,y;
void update(int x,int l,int r,int z,int q)
{
    if (l==r)
    {
        t[x].fi+=q;
        t[x].se++;
        return ;
    }
    int m=(l+r)/2;
    if (z<=m)
        update(x*2,l,m,z,q);
    else update(x*2+1,m+1,r,z,q);
    t[x].fi=t[x*2].fi+t[x*2+1].fi;
    t[x].se=t[x*2].se+t[x*2+1].se;
}
pair <ill,ill> ans(int x,int l,int r,int tl,int tr)
{
    if (tl>tr)return {0,0};
    if (l==tl && r==tr)return {t[x].fi,t[x].se};
    int m=(l+r)/2;
    pair<ill,ill> xx=ans(x*2,l,m,tl,min(m,tr));
    pair<ill,ill> yy=ans(x*2+1,m+1,r,max(tl,m+1),tr);
    return {xx.fi+yy.fi,xx.se+yy.se};
}
int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    cin>>n;
    for (i=1;i<=n;i++)
    {
        cin>>a[i];
        b.insert(a[i]);
    }
    while (!b.empty())
    {
        k++;
        ill z=*b.begin();
        b.erase(z);
        d[z]=k;
        c[k]=z;
    }
    for (i=n;i>0;i--)
    {
        int w=d[a[i]];
        int x1=w-1,x2=w+1;
        x=y={0,0};
        if (x1>0 && abs(c[w]-c[x1])<=1)
            x1--;
        if (x2<=k && abs(c[w]-c[x2])<=1)
            x2++;
        if (x1>0)
        {
            x=ans(1,1,k,1,x1);
        }
        if (x2<=k)
        {
            y=ans(1,1,k,x2,k);
        }
        update(1,1,k,w,a[i]);
        c1[i]=(y.fi+x.fi)-a[i]*(y.se+x.se);
    }
    sort(c1+1,c1+n+1);
    for (i=1;i<=n/2;i++)
    {
        sum+=c1[i];
        sum+=c1[n-i+1];
    }
    if (n%2)sum+=c1[n/2+1];
    cout<<sum<<endl;
}


#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
typedef int ll;
using namespace std;
ll n,i,j,k,x,y,w,m,Q, used[100500], start;
ll a[100500], b[100500], c[100500];
vector<pii> g[100500];
vector<ll> f[100500];
long long d[100500];
long long hea[200500];
int new_w[100500], new_d[100500];
int hea2[200500];
int st[100500], sz[100500], cur_pos[100500];
int G[100500];
ll heapSize;
void add(pair<long long,int> value)
{
    hea[heapSize++] = value.X;
    int i = heapSize - 1;
    hea2[i] = value.Y;
    int parent = ((i - 1)>>1);
    while (i > 0 && hea[parent] < hea[i])
    {
        swap(hea[i], hea[parent]);
        swap(hea2[i], hea2[parent]);
        i = parent;
        parent = ((i - 1)>>1);
    }
}
void heapify(int i)
{
    int largestChild;

    for (; ; )
    {
        largestChild = i;

        if (hea[2 * i + 1] > hea[largestChild])
        {
            largestChild = 2 * i + 1;
        }

        if (hea[2 * i + 2] > hea[largestChild])
        {
            largestChild = 2 * i + 2;
        }

        if (largestChild == i)
        {
            break;
        }

        swap(hea[i], hea[largestChild]);
        swap(hea2[i], hea2[largestChild]);
        i = largestChild;
    }
}
pair<long long,int> getMax()
{
    pii result = mp(hea[0],hea2[0]);

    heapSize--;
    hea[0] = hea[heapSize];
    hea2[0] = hea2[heapSize];
    hea[heapSize] = -(long long)1e+18;
    heapify(0);
    return result;
}

inline unsigned int readUInt()
{
  int c = getc(stdin);
  unsigned int x = 0;
  while (c <= 32)
    c = getc(stdin);
  while ('0' <= c && c <= '9')
    x = x * 10 + c - '0', c = getc(stdin);
  return x;
}
int main() {
    //freopen("input.txt", "r", stdin);
    cin >> n >> m >> Q;
    for (i = 0; i <= 200000; i++)
        hea[i] = -(long long)1e+18;
    for (i = 0; i < m; i++)
    {
        int x,y,z;
        a[i] = readUInt();
        b[i] = readUInt();
        c[i] = readUInt();
    }
    int s = 1;
    for (i = 0; i < m; i++)
    {
        g[a[i]].push_back(mp(b[i], c[i]));
    }
    st[1] = 0;
    sz[1] = g[1].size();
    for (i = 2; i <= n; i++)
    {
        st[i] = cur_pos[i] = st[i-1] + g[i-1].size();
        sz[i] = g[i].size();
    }
    for (i = 0; i < m; i++)
    {
        G[cur_pos[a[i]]++] = i;
    }
    for (i = 1; i <= n; i++)
        d[i] = (long long)1e+18;
    d[s] = 0;
    for (i = 0; i < heapSize; i++)
        hea[i] = -(long long)1e+18;
    heapSize = 0;
    add(make_pair (0, s));
    while (heapSize) {
        pii tmp = getMax();
        int v = tmp.second; long long cur_d = -tmp.first;
        if (cur_d > d[v])  continue;

        for (size_t j=0; j<g[v].size(); ++j) {
            int to = g[v][j].first;
            long long len = g[v][j].second;
            if (d[v] + len < d[to]) {
                d[to] = d[v] + len;
                add(make_pair (-d[to], to));
            }
        }
    }
    for (i = 0; i < m; i++)
        new_w[i] = min(100000000LL, c[i] + d[a[i]] - d[b[i]]);
    for (int ii = 0; ii < Q; ii++)
    {
        ll test;
        cin >> test;
        if (test == 1)
        {
            ll t;
            cin >> t;
            if (d[t] == (long long)1e+18)
                cout << -1 << endl;
            else
                cout << d[t] << endl;
        } else
        {
            cin >> x;
            for (i = 0; i < x; i++)
            {
                int y = readUInt();
                new_w[y-1]++;
                c[y-1]++;
            }
            for (i = 0; i <= n; i++)
            {
                f[i].clear();
                new_d[i] = (int)1e+9;
            }
            f[0].push_back(1);
            new_d[1] = 0;
            for (i = 0; i <= x; i++)
            {
                for (j = 0; j < f[i].size(); j++)
                {
                    int v = f[i][j];
                    if (new_d[v] == i)
                    {
                        for (k = st[v]; k < st[v]+sz[v]; k++)
                        {
                            int to = b[G[k]];
                            int val = new_w[G[k]];
                            if (new_d[to] > i + val)
                            {
                                new_d[to] = min(100000000, i + val);
                                if (new_d[to] <= x)
                                    f[new_d[to]].push_back(to);
                            }
                        }
                    }
                }
            }
            for (i = 1; i <= n; i++)
            {
                d[i] += new_d[i];
                if (d[i] > (long long)1e+18)
                    d[i] = (long long)1e+18;
            }
            for (i = 0; i < m; i++)
                new_w[i] = min(100000000LL, c[i] + d[a[i]] - d[b[i]]);
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
typedef int ll;
using namespace std;
ll n,i,j,k,x,y,w,m,Q, used[100500], start;
pair<pii,ll> a[100500];
vector<pii> g[200500];
vector<ll> f[200500];
long long d[100500];
long long hea[200500];
int new_w[100500], new_d[100500];
int hea2[200500];
ll heapSize;
void add(pair<long long,int> value)
{
    hea[heapSize++] = value.X;
    int i = heapSize - 1;
    hea2[i] = value.Y;
    int parent = ((i - 1)>>1);
    while (i > 0 && hea[parent] < hea[i])
    {
        swap(hea[i], hea[parent]);
        swap(hea2[i], hea2[parent]);
        i = parent;
        parent = ((i - 1)>>1);
    }
}
void heapify(int i)
{
    int largestChild;

    for (; ; )
    {
        largestChild = i;

        if (hea[2 * i + 1] > hea[largestChild])
        {
            largestChild = 2 * i + 1;
        }

        if (hea[2 * i + 2] > hea[largestChild])
        {
            largestChild = 2 * i + 2;
        }

        if (largestChild == i)
        {
            break;
        }

        swap(hea[i], hea[largestChild]);
        swap(hea2[i], hea2[largestChild]);
        i = largestChild;
    }
}
pair<long long,int> getMax()
{
    pii result = mp(hea[0],hea2[0]);

    heapSize--;
    hea[0] = hea[heapSize];
    hea2[0] = hea2[heapSize];
    hea[heapSize] = -(ll)1e+18;
    heapify(0);
    return result;
}

inline unsigned int readUInt()
{
  int c = getc(stdin);
  unsigned int x = 0;
  while (c <= 32)
    c = getc(stdin);
  while ('0' <= c && c <= '9')
    x = x * 10 + c - '0', c = getc(stdin);
  return x;
}
int main() {
    //freopen("input.txt", "r", stdin);
    cin >> n >> m >> Q;
    for (i = 0; i <= 200000; i++)
        hea[i] = -(ll)1e+18;
    for (i = 0; i < m; i++)
    {
        int x,y,z;
        x = readUInt();
        y = readUInt();
        z = readUInt();
        a[i] = mp(mp(x,y),z);
    }
    int s = 1;
    for (i = 0; i < m; i++)
    {
        g[a[i].X.X].push_back(mp(a[i].X.Y, a[i].Y));
    }
    for (i = 1; i <= n; i++)
        d[i] = (ll)1e+18;
    d[s] = 0;
    for (i = 0; i < heapSize; i++)
        hea[i] = -(ll)1e+18;
    heapSize = 0;
    add(make_pair (0, s));
    while (heapSize) {
        pii tmp = getMax();
        int v = tmp.second; long long cur_d = -tmp.first;
        if (cur_d > d[v])  continue;

        for (size_t j=0; j<g[v].size(); ++j) {
            int to = g[v][j].first;
            long long len = g[v][j].second;
            if (d[v] + len < d[to]) {
                d[to] = d[v] + len;
                add(make_pair (-d[to], to));
            }
        }
    }
    for (i = 0; i < m; i++)
        new_w[i] = min(100000000LL, a[i].Y + d[a[i].X.X] - d[a[i].X.Y]);
    for (int ii = 0; ii < Q; ii++)
    {
        ll test;
        cin >> test;
        if (test == 1)
        {
            ll t;
            cin >> t;
            if (d[t] == (ll)1e+18)
                cout << -1 << endl;
            else
                cout << d[t] << endl;
        } else
        {
            cin >> x;
            for (i = 0; i < x; i++)
            {
                int y = readUInt();
                new_w[y-1]++;
                a[y-1].Y++;
            }
            for (i = 1; i <= n; i++)
                g[i].clear();
            for (i = 0; i < m; i++)
            {
                g[a[i].X.X].push_back(mp(a[i].X.Y, new_w[i]));
            }
            for (i = 0; i <= n; i++)
            {
                f[i].clear();
                new_d[i] = (int)1e+9;
            }
            f[0].push_back(1);
            new_d[1] = 0;
            for (i = 0; i < n; i++)
            {
                for (j = 0; j < f[i].size(); j++)
                {
                    int v = f[i][j];
                    if (new_d[v] == i)
                    {
                        for (k = 0; k < g[v].size(); k++)
                        {
                            int to = g[v][k].X;
                            int val = g[v][k].Y;
                            if (new_d[to] > i + val)
                            {
                                new_d[to] = min(100000000, i + val);
                                if (new_d[to] <= n)
                                    f[new_d[to]].push_back(to);
                            }
                        }
                    }
                }
            }
            for (i = 1; i <= n; i++)
            {
                d[i] += new_d[i];
                if (d[i] > (ll)1e+18)
                    d[i] = (ll)1e+18;
            }
            for (i = 0; i < m; i++)
                new_w[i] = min(100000000LL, a[i].Y + d[a[i].X.X] - d[a[i].X.Y]);
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
typedef int ll;
using namespace std;
ll n,i,j,k,x,y,w,m,Q, used[100500], start;
ll a[100500], b[100500], c[100500];
vector<pii> g[100500];
vector<ll> f[1000500];
long long d[100500];
long long hea[200500];
int new_w[100500], new_d[100500];
int hea2[200500];
int st[100500], sz[100500], cur_pos[100500];
int G[100500];
ll heapSize;
void add(pair<long long,int> value)
{
    hea[heapSize++] = value.X;
    int i = heapSize - 1;
    hea2[i] = value.Y;
    int parent = ((i - 1)>>1);
    while (i > 0 && hea[parent] < hea[i])
    {
        swap(hea[i], hea[parent]);
        swap(hea2[i], hea2[parent]);
        i = parent;
        parent = ((i - 1)>>1);
    }
}
void heapify(int i)
{
    int largestChild;

    for (; ; )
    {
        largestChild = i;

        if (hea[2 * i + 1] > hea[largestChild])
        {
            largestChild = 2 * i + 1;
        }

        if (hea[2 * i + 2] > hea[largestChild])
        {
            largestChild = 2 * i + 2;
        }

        if (largestChild == i)
        {
            break;
        }

        swap(hea[i], hea[largestChild]);
        swap(hea2[i], hea2[largestChild]);
        i = largestChild;
    }
}
pair<long long,int> getMax()
{
    pii result = mp(hea[0],hea2[0]);

    heapSize--;
    hea[0] = hea[heapSize];
    hea2[0] = hea2[heapSize];
    hea[heapSize] = -(long long)1e+18;
    heapify(0);
    return result;
}

inline unsigned int readUInt()
{
  int c = getc(stdin);
  unsigned int x = 0;
  while (c <= 32)
    c = getc(stdin);
  while ('0' <= c && c <= '9')
    x = x * 10 + c - '0', c = getc(stdin);
  return x;
}
int main() {
    //freopen("input.txt", "r", stdin);
    cin >> n >> m >> Q;
    for (i = 0; i <= 200000; i++)
        hea[i] = -(long long)1e+18;
    for (i = 0; i <= 1000; i++)
        f[i].reserve(100000);
    for (i = 0; i < m; i++)
    {
        int x,y,z;
        a[i] = readUInt();
        b[i] = readUInt();
        c[i] = readUInt();
    }
    int s = 1;
    for (i = 0; i < m; i++)
    {
        g[a[i]].push_back(mp(b[i], c[i]));
    }
    st[1] = 0;
    sz[1] = g[1].size();
    for (i = 2; i <= n; i++)
    {
        st[i] = cur_pos[i] = st[i-1] + g[i-1].size();
        sz[i] = g[i].size();
    }
    for (i = 0; i < m; i++)
    {
        G[cur_pos[a[i]]++] = i;
    }
    for (i = 1; i <= n; i++)
        d[i] = (long long)1e+18;
    d[s] = 0;
    for (i = 0; i < heapSize; i++)
        hea[i] = -(long long)1e+18;
    heapSize = 0;
    add(make_pair (0, s));
    while (heapSize) {
        pii tmp = getMax();
        int v = tmp.second; long long cur_d = -tmp.first;
        if (cur_d > d[v])  continue;

        for (size_t j=0; j<g[v].size(); ++j) {
            int to = g[v][j].first;
            long long len = g[v][j].second;
            if (d[v] + len < d[to]) {
                d[to] = d[v] + len;
                add(make_pair (-d[to], to));
            }
        }
    }
    for (i = 0; i < m; i++)
        new_w[i] = min(100000000LL, c[i] + d[a[i]] - d[b[i]]);
    int last_test = 1;
    for (int ii = 0; ii < Q; ii++)
    {
        ll test;
        cin >> test;
        if (test == 1)
        {
            if (last_test == 2)
            {
                for (i = 0; i <= n; i++)
                {
                    new_d[i] = (int)1e+9;
                }
                for (i = 0; i <= x; i++)
                    f[i].clear();
                f[0].push_back(1);
                new_d[1] = 0;
                for (i = 0; i <= x; i++)
                {
                    for (j = 0; j < f[i].size(); j++)
                    {
                        int v = f[i][j];
                        if (new_d[v] == i)
                        {
                            int tmp = st[v] + sz[v];
                            for (k = st[v]; k < tmp; k++)
                            {
                                int to = b[G[k]];
                                int val = new_w[G[k]];
                                if (i+val <= x && new_d[to] > i + val)
                                {
                                    new_d[to] = i + val;
                                    f[i+val].push_back(to);
                                }
                            }
                        }
                    }
                }
                for (i = 1; i <= n; i++)
                {
                    d[i] += new_d[i];
                }
                for (i = 0; i < m; i++)
                    new_w[i] = c[i] + d[a[i]] - d[b[i]];
            }
            ll t;
            cin >> t;
            if (d[t] >= (long long)1e+18)
                cout << -1 << endl;
            else
                cout << d[t] << endl;
        } else
        {
            int tmp;
            if (last_test == 1)
                x = 0;
            cin >> tmp;
            for (i = 0; i < tmp; i++)
            {
                int y = readUInt();
                new_w[y-1]++;
                c[y-1]++;
            }
            x += tmp;
        }
        last_test = test;
    }
    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
typedef int ll;
using namespace std;
ll n,i,j,k,x,y,w,m,Q, used[100500], start;
pair<pii,ll> a[100500];
vector<pii> g[200500];
vector<ll> f[200500];
long long d[100500];
long long hea[200500];
int new_w[100500], new_d[100500];
int hea2[200500];
ll heapSize;
void add(pair<long long,int> value)
{
    hea[heapSize++] = value.X;
    int i = heapSize - 1;
    hea2[i] = value.Y;
    int parent = ((i - 1)>>1);
    while (i > 0 && hea[parent] < hea[i])
    {
        swap(hea[i], hea[parent]);
        swap(hea2[i], hea2[parent]);
        i = parent;
        parent = ((i - 1)>>1);
    }
}
void heapify(int i)
{
    int largestChild;

    for (; ; )
    {
        largestChild = i;

        if (hea[2 * i + 1] > hea[largestChild])
        {
            largestChild = 2 * i + 1;
        }

        if (hea[2 * i + 2] > hea[largestChild])
        {
            largestChild = 2 * i + 2;
        }

        if (largestChild == i)
        {
            break;
        }

        swap(hea[i], hea[largestChild]);
        swap(hea2[i], hea2[largestChild]);
        i = largestChild;
    }
}
pair<long long,int> getMax()
{
    pii result = mp(hea[0],hea2[0]);

    heapSize--;
    hea[0] = hea[heapSize];
    hea2[0] = hea2[heapSize];
    hea[heapSize] = -(long long)1e+18;
    heapify(0);
    return result;
}

inline unsigned int readUInt()
{
  int c = getc(stdin);
  unsigned int x = 0;
  while (c <= 32)
    c = getc(stdin);
  while ('0' <= c && c <= '9')
    x = x * 10 + c - '0', c = getc(stdin);
  return x;
}
int main() {
    //freopen("input.txt", "r", stdin);
    cin >> n >> m >> Q;
    for (i = 0; i <= 200000; i++)
        hea[i] = -(long long)1e+18;
    for (i = 0; i < m; i++)
    {
        int x,y,z;
        x = readUInt();
        y = readUInt();
        z = readUInt();
        a[i] = mp(mp(x,y),z);
    }
    int s = 1;
    for (i = 0; i < m; i++)
    {
        g[a[i].X.X].push_back(mp(a[i].X.Y, a[i].Y));
    }
    for (i = 1; i <= n; i++)
        d[i] = (long long)1e+18;
    d[s] = 0;
    for (i = 0; i < heapSize; i++)
        hea[i] = -(long long)1e+18;
    heapSize = 0;
    add(make_pair (0, s));
    while (heapSize) {
        pii tmp = getMax();
        int v = tmp.second; long long cur_d = -tmp.first;
        if (cur_d > d[v])  continue;

        for (size_t j=0; j<g[v].size(); ++j) {
            int to = g[v][j].first;
            long long len = g[v][j].second;
            if (d[v] + len < d[to]) {
                d[to] = d[v] + len;
                add(make_pair (-d[to], to));
            }
        }
    }
    for (i = 0; i < m; i++)
        new_w[i] = min(100000000LL, a[i].Y + d[a[i].X.X] - d[a[i].X.Y]);
    for (int ii = 0; ii < Q; ii++)
    {
        ll test;
        cin >> test;
        if (test == 1)
        {
            ll t;
            cin >> t;
            if (d[t] == (long long)1e+18)
                cout << -1 << endl;
            else
                cout << d[t] << endl;
        } else
        {
            cin >> x;
            for (i = 0; i < x; i++)
            {
                int y = readUInt();
                new_w[y-1]++;
                a[y-1].Y++;
            }
            for (i = 1; i <= n; i++)
                g[i].clear();
            for (i = 0; i < m; i++)
            {
                g[a[i].X.X].push_back(mp(a[i].X.Y, new_w[i]));
            }
            for (i = 0; i <= n; i++)
            {
                f[i].clear();
                new_d[i] = (int)1e+9;
            }
            f[0].push_back(1);
            new_d[1] = 0;
            for (i = 0; i < n; i++)
            {
                for (j = 0; j < f[i].size(); j++)
                {
                    int v = f[i][j];
                    if (new_d[v] == i)
                    {
                        for (k = 0; k < g[v].size(); k++)
                        {
                            int to = g[v][k].X;
                            int val = g[v][k].Y;
                            if (new_d[to] > i + val)
                            {
                                new_d[to] = min(100000000, i + val);
                                if (new_d[to] <= n)
                                    f[new_d[to]].push_back(to);
                            }
                        }
                    }
                }
            }
            for (i = 1; i <= n; i++)
            {
                d[i] += new_d[i];
                if (d[i] > (long long)1e+18)
                    d[i] = (long long)1e+18;
            }
            for (i = 0; i < m; i++)
                new_w[i] = min(100000000LL, a[i].Y + d[a[i].X.X] - d[a[i].X.Y]);
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
typedef long long ll;
using namespace std;
ll n,i,j,k,x,y,w,m,Q, used[100500], start;
pair<pii,ll> a[100500];
vector<pii> g[200500];
ll d[100500], p[100500];
ll hea[100500];
int hea2[100500];
ll heapSize;
void add(pii value)
{
    hea[heapSize++] = value.X;
    int i = heapSize - 1;
    hea2[i] = value.Y;
    int parent = ((i - 1)>>1);
    while (i > 0 && hea[parent] < hea[i])
    {
        swap(hea[i], hea[parent]);
        swap(hea2[i], hea2[parent]);
        i = parent;
        parent = ((i - 1)>>1);
    }
}
void heapify(int i)
{
    int largestChild;

    for (; ; )
    {
        largestChild = i;

        if (2 * i + 1 < heapSize && hea[2 * i + 1] > hea[largestChild])
        {
            largestChild = 2 * i + 1;
        }

        if (2 * i + 2 < heapSize && hea[2 * i + 2] > hea[largestChild])
        {
            largestChild = 2 * i + 2;
        }

        if (largestChild == i)
        {
            break;
        }

        swap(hea[i], hea[largestChild]);
        swap(hea2[i], hea2[largestChild]);
        i = largestChild;
    }
}
pii getMax()
{
    pii result = mp(hea[0],hea2[0]);

    heapSize--;
    hea[0] = hea[heapSize];
    hea2[0] = hea2[heapSize];
    heapify(0);
    return result;
}

inline unsigned int readUInt()
{
  int c = getc(stdin);
  unsigned int x = 0;
  while (c <= 32)
    c = getc(stdin);
  while ('0' <= c && c <= '9')
    x = x * 10 + c - '0', c = getc(stdin);
  return x;
}
int main() {
    //freopen("input.txt", "r", stdin);
    cin >> n >> m >> Q;
    for (i = 0; i < m; i++)
    {
        int x,y,z;
        x = readUInt();
        y = readUInt();
        z = readUInt();
        a[i] = mp(mp(x,y),z);
    }
    int was_changed = 1;
    for (int ii = 0; ii < Q; ii++)
    {
        ll test;
        cin >> test;
        if (test == 1)
        {
            ll t;
            cin >> t;

            if (was_changed)
            {
            int s = 1;
            for (i = 1; i <= n; i++)
                g[i].clear();
            for (i = 0; i < m; i++)
            {
                g[a[i].X.X].push_back(mp(a[i].X.Y, a[i].Y));
            }
            for (i = 1; i <= n; i++)
                d[i] = (ll)1e+18;
            d[s] = 0;
            heapSize = 0;
            add(make_pair (0, s));
            while (heapSize) {
                pii tmp = getMax();
                ll v = tmp.second,  cur_d = -tmp.first;
                if (cur_d > d[v])  continue;

                for (size_t j=0; j<g[v].size(); ++j) {
                    ll to = g[v][j].first,
                        len = g[v][j].second;
                    if (d[v] + len < d[to]) {
                        d[to] = d[v] + len;
                        p[to] = v;
                        add(make_pair (-d[to], to));
                    }
                }
            }
            }
            if (d[t] == (ll)1e+18)
                cout << -1 << endl;
            else
                cout << d[t] << endl;
        } else
        {
            was_changed = 1;
            cin >> x;
            for (i = 0; i < x; i++)
            {
                int y;
                y = readUInt();
                a[y-1].Y++;
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
typedef long long ll;
using namespace std;
ll n,i,j,k,x,y,w,m,Q, used[100500], start;
pair<pii,ll> a[100500];
vector<pii> g[200500];
ll d[100500], p[100500];
priority_queue < pair<int,int> > q;
int main() {
    freopen("input.txt", "r", stdin);
    cin >> n >> m >> Q;
    for (i = 0; i < m; i++)
    {
        int x,y,z;
        scanf("%d %d %d",&x,&y,&z);
        a[i] = mp(mp(x,y),z);
    }
    for (int ii = 0; ii < Q; ii++)
    {
        ll test;
        cin >> test;
        if (test == 1)
        {
            ll t;
            cin >> t;
            int s = 1;
            for (i = 1; i <= n; i++)
                g[i].clear();
            for (i = 0; i < m; i++)
            {
                g[a[i].X.X].push_back(mp(a[i].X.Y, a[i].Y));
                g[a[i].X.Y].push_back(mp(a[i].X.X, a[i].Y));
            }
            for (i = 1; i <= n; i++)
                d[i] = (ll)1e+18;
            d[s] = 0;
            while (!q.empty())
                q.pop();
            q.push (make_pair (0, s));
            while (!q.empty()) {
                ll v = q.top().second,  cur_d = -q.top().first;
                if (v == t)
                    break;
                q.pop();
                if (cur_d > d[v])  continue;

                for (size_t j=0; j<g[v].size(); ++j) {
                    int to = g[v][j].first,
                        len = g[v][j].second;
                    if (d[v] + len < d[to]) {
                        d[to] = d[v] + len;
                        p[to] = v;
                        q.push (make_pair (-d[to], to));
                    }
                }
            }
            if (d[t] == (ll)1e+18)
                cout << -1 << endl;
            else
                cout << d[t] << endl;
        } else
        {
            cin >> x;
            for (i = 0; i < x; i++)
            {
                cin >> y;
                a[y-1].Y++;
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
typedef long long ll;
using namespace std;
ll n,i,j,k,x,y,w,m,Q, used[100500], start;
pair<pii,ll> a[100500];
vector<pii> g[200500];
ll d[100500], p[100500];
ll hea[100500];
int hea2[100500];
ll heapSize;
void add(pii value)
{
    hea[heapSize++] = value.X;
    int i = heapSize - 1;
    hea[i] = value.Y;
    int parent = ((i - 1)>>1);
    while (i > 0 && hea[parent] < hea[i])
    {
        swap(hea[i], hea[parent]);
        swap(hea2[i], hea2[parent]);
        i = parent;
        parent = ((i - 1)>>1);
    }
}
void heapify(int i)
{
    int largestChild;

    for (; ; )
    {
        largestChild = i;

        if (2 * i + 1 < heapSize && hea[2 * i + 1] > hea[largestChild])
        {
            largestChild = 2 * i + 1;
        }

        if (2 * i + 2 < heapSize && hea[2 * i + 2] > hea[largestChild])
        {
            largestChild = 2 * i + 2;
        }

        if (largestChild == i)
        {
            break;
        }

        swap(hea[i], hea[largestChild]);
        swap(hea2[i], hea2[largestChild]);
        i = largestChild;
    }
}
pii getMax()
{
    pii result = mp(hea[0],hea2[0]);
    hea[0] = hea[heapSize - 1];
    hea2[0] = hea2[heapSize - 1];
    heapSize--;
    heapify(0);
    return result;
}

inline unsigned int readUInt()
{
  int c = getc(stdin);
  unsigned int x = 0;
  while (c <= 32)
    c = getc(stdin);
  while ('0' <= c && c <= '9')
    x = x * 10 + c - '0', c = getc(stdin);
  return x;
}
int main() {
    //freopen("input.txt", "r", stdin);
    cin >> n >> m >> Q;
    for (i = 0; i < m; i++)
    {
        int x,y,z;
        scanf("%d %d %d",&x,&y,&z);
        a[i] = mp(mp(x,y),z);
    }
    int was_changed = 1;
    for (int ii = 0; ii < Q; ii++)
    {
        ll test;
        cin >> test;
        if (test == 1)
        {
            ll t;
            cin >> t;

            if (was_changed)
            {
            int s = 1;
            for (i = 1; i <= n; i++)
                g[i].clear();
            for (i = 0; i < m; i++)
            {
                g[a[i].X.X].push_back(mp(a[i].X.Y, a[i].Y));
            }
            for (i = 1; i <= n; i++)
                d[i] = (ll)1e+18;
            d[s] = 0;
            heapSize = 0;
            add(make_pair (0, s));
            while (heapSize) {
                pii tmp = getMax();
                ll v = tmp.second,  cur_d = -tmp.first;
                if (cur_d > d[v])  continue;

                for (size_t j=0; j<g[v].size(); ++j) {
                    ll to = g[v][j].first,
                        len = g[v][j].second;
                    if (d[v] + len < d[to]) {
                        d[to] = d[v] + len;
                        p[to] = v;
                        add(make_pair (-d[to], to));
                    }
                }
            }
            }
            if (d[t] == (ll)1e+18)
                cout << -1 << endl;
            else
                cout << d[t] << endl;
        } else
        {
            was_changed = 1;
            cin >> x;
            for (i = 0; i < x; i++)
            {
                int y;
                y = readUInt();
                a[y-1].Y++;
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
typedef int ll;
using namespace std;
ll n,i,j,k,x,y,w,m,Q, used[100500], start;
ll a[100500], b[100500], c[100500];
vector<pii> g[100500];
vector<ll> f[1000500];
long long d[100500];
long long hea[200500];
int new_w[100500], new_d[100500];
int hea2[200500];
int st[100500], sz[100500], cur_pos[100500];
int G[100500];
ll heapSize;
void add(pair<long long,int> value)
{
    hea[heapSize++] = value.X;
    int i = heapSize - 1;
    hea2[i] = value.Y;
    int parent = ((i - 1)>>1);
    while (i > 0 && hea[parent] < hea[i])
    {
        swap(hea[i], hea[parent]);
        swap(hea2[i], hea2[parent]);
        i = parent;
        parent = ((i - 1)>>1);
    }
}
void heapify(int i)
{
    int largestChild;

    for (; ; )
    {
        largestChild = i;

        if (hea[2 * i + 1] > hea[largestChild])
        {
            largestChild = 2 * i + 1;
        }

        if (hea[2 * i + 2] > hea[largestChild])
        {
            largestChild = 2 * i + 2;
        }

        if (largestChild == i)
        {
            break;
        }

        swap(hea[i], hea[largestChild]);
        swap(hea2[i], hea2[largestChild]);
        i = largestChild;
    }
}
pair<long long,int> getMax()
{
    pii result = mp(hea[0],hea2[0]);

    heapSize--;
    hea[0] = hea[heapSize];
    hea2[0] = hea2[heapSize];
    hea[heapSize] = -(long long)1e+18;
    heapify(0);
    return result;
}

inline unsigned int readUInt()
{
  int c = getc(stdin);
  unsigned int x = 0;
  while (c <= 32)
    c = getc(stdin);
  while ('0' <= c && c <= '9')
    x = x * 10 + c - '0', c = getc(stdin);
  return x;
}
int main() {
    //freopen("input.txt", "r", stdin);
    cin >> n >> m >> Q;
    for (i = 0; i <= 200000; i++)
        hea[i] = -(long long)1e+18;
    for (i = 0; i <= 1000; i++)
        f[i].reserve(100000);
    for (i = 0; i < m; i++)
    {
        int x,y,z;
        a[i] = readUInt();
        b[i] = readUInt();
        c[i] = readUInt();
    }
    int s = 1;
    for (i = 0; i < m; i++)
    {
        g[a[i]].push_back(mp(b[i], c[i]));
    }
    st[1] = 0;
    sz[1] = g[1].size();
    for (i = 2; i <= n; i++)
    {
        st[i] = cur_pos[i] = st[i-1] + g[i-1].size();
        sz[i] = g[i].size();
    }
    for (i = 0; i < m; i++)
    {
        G[cur_pos[a[i]]++] = i;
    }
    for (i = 1; i <= n; i++)
        d[i] = (long long)1e+18;
    d[s] = 0;
    for (i = 0; i < heapSize; i++)
        hea[i] = -(long long)1e+18;
    heapSize = 0;
    add(make_pair (0, s));
    while (heapSize) {
        pii tmp = getMax();
        int v = tmp.second; long long cur_d = -tmp.first;
        if (cur_d > d[v])  continue;

        for (size_t j=0; j<g[v].size(); ++j) {
            int to = g[v][j].first;
            long long len = g[v][j].second;
            if (d[v] + len < d[to]) {
                d[to] = d[v] + len;
                add(make_pair (-d[to], to));
            }
        }
    }
    for (i = 0; i < m; i++)
        new_w[i] = min(100000000LL, c[i] + d[a[i]] - d[b[i]]);
    int last_test = 1;
    for (int ii = 0; ii < Q; ii++)
    {
        ll test;
        cin >> test;
        if (test == 1)
        {
            if (last_test == 2)
            {
                for (i = 0; i <= n; i++)
                {
                    new_d[i] = (int)1e+9;
                }
                for (i = 0; i <= x; i++)
                    f[i].clear();
                f[0].push_back(1);
                new_d[1] = 0;
                for (i = 0; i <= x; i++)
                {
                    for (j = 0; j < f[i].size(); j++)
                    {
                        int v = f[i][j];
                        if (new_d[v] == i)
                        {
                            int tmp = st[v] + sz[v];
                            for (k = st[v]; k < tmp; k++)
                            {
                                int to = b[G[k]];
                                int val = new_w[G[k]];
                                if (new_d[to] > i + val)
                                {
                                    new_d[to] = min(100000000, i + val);
                                    if (new_d[to] <= x)
                                        f[new_d[to]].push_back(to);
                                }
                            }
                        }
                    }
                }
                for (i = 1; i <= n; i++)
                {
                    d[i] += new_d[i];
                    if (d[i] > (long long)1e+18)
                        d[i] = (long long)1e+18;
                }
                for (i = 0; i < m; i++)
                    new_w[i] = min(100000000LL, c[i] + d[a[i]] - d[b[i]]);
            }
            ll t;
            cin >> t;
            if (d[t] == (long long)1e+18)
                cout << -1 << endl;
            else
                cout << d[t] << endl;
        } else
        {
            int tmp;
            if (last_test == 1)
                x = 0;
            cin >> tmp;
            for (i = 0; i < tmp; i++)
            {
                int y = readUInt();
                new_w[y-1]++;
                c[y-1]++;
            }
            x += tmp;
        }
        last_test = test;
    }
    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
typedef long long ll;
using namespace std;
ll n,i,j,k,x,y,w,m,Q, used[100500], start;
pair<pii,ll> a[100500];
vector<pii> g[200500];
ll d[100500], p[100500];
ll hea[100500];
int hea2[100500];
ll heapSize;
void add(pii value)
{
    hea[heapSize++] = value.X;
    int i = heapSize - 1;
    hea2[i] = value.Y;
    int parent = ((i - 1)>>1);
    while (i > 0 && hea[parent] < hea[i])
    {
        swap(hea[i], hea[parent]);
        swap(hea2[i], hea2[parent]);
        i = parent;
        parent = ((i - 1)>>1);
    }
}
void heapify(int i)
{
    int largestChild;

    for (; ; )
    {
        largestChild = i;

        if (2 * i + 1 < heapSize && hea[2 * i + 1] > hea[largestChild])
        {
            largestChild = 2 * i + 1;
        }

        if (2 * i + 2 < heapSize && hea[2 * i + 2] > hea[largestChild])
        {
            largestChild = 2 * i + 2;
        }

        if (largestChild == i)
        {
            break;
        }

        swap(hea[i], hea[largestChild]);
        swap(hea2[i], hea2[largestChild]);
        i = largestChild;
    }
}
pii getMax()
{
    pii result = mp(hea[0],hea2[0]);

    heapSize--;
    hea[0] = hea[heapSize];
    hea2[0] = hea2[heapSize];
    heapify(0);
    return result;
}

inline unsigned int readUInt()
{
  int c = getc(stdin);
  unsigned int x = 0;
  while (c <= 32)
    c = getc(stdin);
  while ('0' <= c && c <= '9')
    x = x * 10 + c - '0', c = getc(stdin);
  return x;
}
int main() {
    //freopen("input.txt", "r", stdin);
    cin >> n >> m >> Q;
    for (i = 0; i < m; i++)
    {
        int x,y,z;
        x = readUInt();
        y = readUInt();
        z = readUInt();
        a[i] = mp(mp(x,y),z);
    }
    int was_changed = 1;
    for (int ii = 0; ii < Q; ii++)
    {
        ll test;
        cin >> test;
        if (test == 1)
        {
            ll t;
            cin >> t;

            if (was_changed)
            {
            int s = 1;
            for (i = 1; i <= n; i++)
                g[i].clear();
            for (i = 0; i < m; i++)
            {
                g[a[i].X.X].push_back(mp(a[i].X.Y, a[i].Y));
            }
            for (i = 1; i <= n; i++)
                d[i] = (ll)1e+18;
            d[s] = 0;
            heapSize = 0;
            add(make_pair (0, s));
            }
            while (heapSize) {
                pii tmp = getMax();
                ll v = tmp.second,  cur_d = -tmp.first;
                if (cur_d > d[v])  continue;

                for (size_t j=0; j<g[v].size(); ++j) {
                    ll to = g[v][j].first,
                        len = g[v][j].second;
                    if (d[v] + len < d[to]) {
                        d[to] = d[v] + len;
                        p[to] = v;
                        add(make_pair (-d[to], to));
                    }
                }
                if (v == t)
                    break;
            }
            if (d[t] == (ll)1e+18)
                cout << -1 << endl;
            else
                cout << d[t] << endl;
        } else
        {
            was_changed = 1;
            cin >> x;
            for (i = 0; i < x; i++)
            {
                int y;
                y = readUInt();
                a[y-1].Y++;
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
typedef int ll;
using namespace std;
ll n,i,j,k,x,y,w,m,Q, used[100500], start;
pair<pii,ll> a[100500];
vector<pii> g[100500];
long long d[100500];
long long hea[200500];
int new_w[100500], new_d[100500];
int hea2[200500];
int st[100500], sz[100500], cur_pos[100500];
pii G[100500];
int F[100500000], stF[100500], finF[100500], curF[100500];
ll heapSize;
void add(pair<long long,int> value)
{
    hea[heapSize++] = value.X;
    int i = heapSize - 1;
    hea2[i] = value.Y;
    int parent = ((i - 1)>>1);
    while (i > 0 && hea[parent] < hea[i])
    {
        swap(hea[i], hea[parent]);
        swap(hea2[i], hea2[parent]);
        i = parent;
        parent = ((i - 1)>>1);
    }
}
void heapify(int i)
{
    int largestChild;

    for (; ; )
    {
        largestChild = i;

        if (hea[2 * i + 1] > hea[largestChild])
        {
            largestChild = 2 * i + 1;
        }

        if (hea[2 * i + 2] > hea[largestChild])
        {
            largestChild = 2 * i + 2;
        }

        if (largestChild == i)
        {
            break;
        }

        swap(hea[i], hea[largestChild]);
        swap(hea2[i], hea2[largestChild]);
        i = largestChild;
    }
}
pair<long long,int> getMax()
{
    pii result = mp(hea[0],hea2[0]);

    heapSize--;
    hea[0] = hea[heapSize];
    hea2[0] = hea2[heapSize];
    hea[heapSize] = -(long long)1e+18;
    heapify(0);
    return result;
}

inline unsigned int readUInt()
{
  int c = getc(stdin);
  unsigned int x = 0;
  while (c <= 32)
    c = getc(stdin);
  while ('0' <= c && c <= '9')
    x = x * 10 + c - '0', c = getc(stdin);
  return x;
}
int main() {
    //freopen("input.txt", "r", stdin);
    cin >> n >> m >> Q;
    for (i = 0; i <= 200000; i++)
        hea[i] = -(long long)1e+18;
    for (i = 0; i < m; i++)
    {
        int x,y,z;
        x = readUInt();
        y = readUInt();
        z = readUInt();
        a[i] = mp(mp(x,y),z);
    }
    int s = 1;
    for (i = 0; i < m; i++)
    {
        g[a[i].X.X].push_back(mp(a[i].X.Y, a[i].Y));
    }
    st[1] = 0;
    sz[1] = g[1].size();
    for (i = 2; i <= n; i++)
    {
        st[i] = st[i-1] + g[i-1].size();
        sz[i] = g[i].size();
    }
    for (i = 1; i <= n; i++)
        d[i] = (long long)1e+18;
    d[s] = 0;
    for (i = 0; i < heapSize; i++)
        hea[i] = -(long long)1e+18;
    heapSize = 0;
    add(make_pair (0, s));
    while (heapSize) {
        pii tmp = getMax();
        int v = tmp.second; long long cur_d = -tmp.first;
        if (cur_d > d[v])  continue;

        for (size_t j=0; j<g[v].size(); ++j) {
            int to = g[v][j].first;
            long long len = g[v][j].second;
            if (d[v] + len < d[to]) {
                d[to] = d[v] + len;
                add(make_pair (-d[to], to));
            }
        }
    }
    for (i = 0; i < m; i++)
        new_w[i] = min(100000000LL, a[i].Y + d[a[i].X.X] - d[a[i].X.Y]);
    for (int ii = 0; ii < Q; ii++)
    {
        ll test;
        cin >> test;
        if (test == 1)
        {
            ll t;
            cin >> t;
            if (d[t] == (long long)1e+18)
                cout << -1 << endl;
            else
                cout << d[t] << endl;
        } else
        {
            cin >> x;
            for (i = 0; i < x; i++)
            {
                int y = readUInt();
                new_w[y-1]++;
                a[y-1].Y++;
            }
            for (i = 1; i <= n; i++)
                cur_pos[i] = st[i];
            for (i = 0; i < m; i++)
            {
                G[cur_pos[a[i].X.X]++] = mp(a[i].X.Y, new_w[i]);
            }
            for (i = 0; i <= n; i++)
            {
                curF[i] = stF[i] = i*500;
                new_d[i] = (int)1e+9;
            }
            int cur_free = n*500+500;
            F[curF[0]++] = 1;
            new_d[1] = 0;
            for (i = 0; i < n; i++)
            {
                int pp = curF[i];
                for (j = stF[i]; j < pp; j++)
                {
                    int v = F[j];
                    if (new_d[v] == i)
                    {
                        for (k = st[v]; k < st[v]+sz[v]; k++)
                        {
                            int to = G[k].X;
                            int val = G[k].Y;
                            if (new_d[to] > i + val)
                            {
                                new_d[to] = min(100000000, i + val);
                                if (new_d[to] <= n)
                                {
                                    int cr = new_d[to];
                                    if (curF[cr] == cr*500+499)
                                    {
                                        for (int ii = 0; ii < 500; ii++)
                                            F[cur_free+ii] = F[stF[cr]+ii];
                                        curF[cr] = cur_free+499;
                                        stF[cr] = cur_free;
                                        cur_free += 100000;
                                    }
                                    F[curF[cr]++] = to;
                                }
                            }
                        }
                    }
                }
            }
            for (i = 1; i <= n; i++)
            {
                d[i] += new_d[i];
                if (d[i] > (long long)1e+18)
                    d[i] = (long long)1e+18;
            }
            for (i = 0; i < m; i++)
                new_w[i] = min(100000000LL, a[i].Y + d[a[i].X.X] - d[a[i].X.Y]);
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
typedef int ll;
using namespace std;
ll n,i,j,k,x,y,w,m,Q, used[100500], start;
ll a[100500], b[100500], c[100500];
vector<pii> g[100500];
stack<ll> f[1000500];
long long d[100500];
long long hea[200500];
int new_w[100500], new_d[100500];
int hea2[200500];
int st[100500], sz[100500], cur_pos[100500];
int G[100500];
ll heapSize;
void add(pair<long long,int> value)
{
    hea[heapSize++] = value.X;
    int i = heapSize - 1;
    hea2[i] = value.Y;
    int parent = ((i - 1)>>1);
    while (i > 0 && hea[parent] < hea[i])
    {
        swap(hea[i], hea[parent]);
        swap(hea2[i], hea2[parent]);
        i = parent;
        parent = ((i - 1)>>1);
    }
}
void heapify(int i)
{
    int largestChild;

    for (; ; )
    {
        largestChild = i;

        if (hea[2 * i + 1] > hea[largestChild])
        {
            largestChild = 2 * i + 1;
        }

        if (hea[2 * i + 2] > hea[largestChild])
        {
            largestChild = 2 * i + 2;
        }

        if (largestChild == i)
        {
            break;
        }

        swap(hea[i], hea[largestChild]);
        swap(hea2[i], hea2[largestChild]);
        i = largestChild;
    }
}
pair<long long,int> getMax()
{
    pii result = mp(hea[0],hea2[0]);

    heapSize--;
    hea[0] = hea[heapSize];
    hea2[0] = hea2[heapSize];
    hea[heapSize] = -(long long)1e+18;
    heapify(0);
    return result;
}

inline unsigned int readUInt()
{
  int c = getc(stdin);
  unsigned int x = 0;
  while (c <= 32)
    c = getc(stdin);
  while ('0' <= c && c <= '9')
    x = x * 10 + c - '0', c = getc(stdin);
  return x;
}
int main() {
    //freopen("input.txt", "r", stdin);
    cin >> n >> m >> Q;
    for (i = 0; i <= 200000; i++)
        hea[i] = -(long long)1e+18;
    for (i = 0; i < m; i++)
    {
        int x,y,z;
        a[i] = readUInt();
        b[i] = readUInt();
        c[i] = readUInt();
    }
    int s = 1;
    for (i = 0; i < m; i++)
    {
        g[a[i]].push_back(mp(b[i], c[i]));
    }
    st[1] = 0;
    sz[1] = g[1].size();
    for (i = 2; i <= n; i++)
    {
        st[i] = cur_pos[i] = st[i-1] + g[i-1].size();
        sz[i] = g[i].size();
    }
    for (i = 0; i < m; i++)
    {
        G[cur_pos[a[i]]++] = i;
    }
    for (i = 1; i <= n; i++)
        d[i] = (long long)1e+18;
    d[s] = 0;
    for (i = 0; i < heapSize; i++)
        hea[i] = -(long long)1e+18;
    heapSize = 0;
    add(make_pair (0, s));
    while (heapSize) {
        pii tmp = getMax();
        int v = tmp.second; long long cur_d = -tmp.first;
        if (cur_d > d[v])  continue;

        for (size_t j=0; j<g[v].size(); ++j) {
            int to = g[v][j].first;
            long long len = g[v][j].second;
            if (d[v] + len < d[to]) {
                d[to] = d[v] + len;
                add(make_pair (-d[to], to));
            }
        }
    }
    for (i = 0; i < m; i++)
        new_w[i] = min(100000000LL, c[i] + d[a[i]] - d[b[i]]);
    int last_test = 1;
    for (int ii = 0; ii < Q; ii++)
    {
        ll test;
        cin >> test;
        if (test == 1)
        {
            if (last_test == 2)
            {
                for (i = 0; i <= n; i++)
                {
                    new_d[i] = (int)1e+9;
                }
                f[0].push(1);
                new_d[1] = 0;
                for (i = 0; i <= x; i++)
                {
                    while (!f[i].empty())
                    {
                        int v = f[i].top();
                        f[i].pop();
                        if (new_d[v] == i)
                        {
                            int tmp = st[v] + sz[v];
                            for (k = st[v]; k < tmp; k++)
                            {
                                int to = b[G[k]];
                                int val = new_w[G[k]];
                                if (new_d[to] > i + val)
                                {
                                    new_d[to] = min(100000000, i + val);
                                    if (new_d[to] <= x)
                                        f[new_d[to]].push(to);
                                }
                            }
                        }
                    }
                }
                for (i = 1; i <= n; i++)
                {
                    d[i] += new_d[i];
                    if (d[i] > (long long)1e+18)
                        d[i] = (long long)1e+18;
                }
                for (i = 0; i < m; i++)
                    new_w[i] = min(100000000LL, c[i] + d[a[i]] - d[b[i]]);
            }
            ll t;
            cin >> t;
            if (d[t] == (long long)1e+18)
                cout << -1 << endl;
            else
                cout << d[t] << endl;
        } else
        {
            int tmp;
            if (last_test == 1)
                x = 0;
            cin >> tmp;
            for (i = 0; i < tmp; i++)
            {
                int y = readUInt();
                new_w[y-1]++;
                c[y-1]++;
            }
            x += tmp;
        }
        last_test = test;
    }
    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
typedef long long ll;
using namespace std;
ll n,i,j,k,x,y,w,m,Q, used[100500], start;
pair<pii,ll> a[100500];
vector<pii> g[200500];
ll d[100500], p[100500];
pii hea[100500];
ll heapSize;
void add(pii value)
{
    hea[heapSize++] = value;
    int i = heapSize - 1;
    int parent = ((i - 1)>>1);
    while (i > 0 && hea[parent] < hea[i])
    {
        swap(hea[i], hea[parent]);
        i = parent;
        parent = ((i - 1)>>1);
    }
}
void heapify(int i)
{
    int largestChild;

    for (; ; )
    {
        largestChild = i;

        if (2 * i + 1 < heapSize && hea[2 * i + 1] > hea[largestChild])
        {
            largestChild = 2 * i + 1;
        }

        if (2 * i + 2 < heapSize && hea[2 * i + 2] > hea[largestChild])
        {
            largestChild = 2 * i + 2;
        }

        if (largestChild == i)
        {
            break;
        }

        swap(hea[i], hea[largestChild]);
        i = largestChild;
    }
}
pii getMax()
{
    pii result = hea[0];
    hea[0] = hea[heapSize - 1];
    heapSize--;
    heapify(0);
    return result;
}
int main() {
    //freopen("input.txt", "r", stdin);
    cin >> n >> m >> Q;
    for (i = 0; i < m; i++)
    {
        int x,y,z;
        scanf("%d %d %d",&x,&y,&z);
        a[i] = mp(mp(x,y),z);
    }
    for (int ii = 0; ii < Q; ii++)
    {
        ll test;
        cin >> test;
        if (test == 1)
        {
            ll t;
            cin >> t;
            int s = 1;
            for (i = 1; i <= n; i++)
                g[i].clear();
            for (i = 0; i < m; i++)
            {
                g[a[i].X.X].push_back(mp(a[i].X.Y, a[i].Y));
            }
            for (i = 1; i <= n; i++)
                d[i] = (ll)1e+18;
            d[s] = 0;
            heapSize = 0;
            add(make_pair (0, s));
            while (heapSize) {
                pii tmp = getMax();
                ll v = tmp.second,  cur_d = -tmp.first;
                if (v == t)
                    break;
                if (cur_d > d[v])  continue;

                for (size_t j=0; j<g[v].size(); ++j) {
                    ll to = g[v][j].first,
                        len = g[v][j].second;
                    if (d[v] + len < d[to]) {
                        d[to] = d[v] + len;
                        p[to] = v;
                        add(make_pair (-d[to], to));
                    }
                }
            }
            if (d[t] == (ll)1e+18)
                cout << -1 << endl;
            else
                cout << d[t] << endl;
        } else
        {
            cin >> x;
            for (i = 0; i < x; i++)
            {
                int y;
                scanf("%d", &y);
                a[y-1].Y++;
            }
        }
    }
    return 0;
}