forked from abheekd/usaco-practice
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
260 B
19 lines
260 B
#include <iostream>
|
|
using namespace std;
|
|
|
|
int main() {
|
|
int n;
|
|
cin >> n;
|
|
int px = 0;
|
|
long long ans = 0;
|
|
for (int i = 0; i < n; i++) {
|
|
int x;
|
|
cin >> x;
|
|
if (x < px) {
|
|
ans += px - x;
|
|
x = px;
|
|
}
|
|
px = x;
|
|
}
|
|
cout << ans;
|
|
}
|
|
|