#include <bits/stdc++.h>
using namespace std;
const int DIM = 25e4 + 7;
long long pos[DIM];
int ord[DIM];
struct Truck {
  long long start;
  long long finish;
  long long cost;
  long long refuel;
};
Truck truck[DIM];
bool check(long long fuel, int id) {
  long long curr = fuel;
  long long refuel = 0;
  for (int city = truck[id].start; city < truck[id].finish; city++) {
    if ((pos[city + 1] - pos[city]) * truck[id].cost > curr) {
      curr = fuel;
      refuel++;
      if (refuel > truck[id].refuel ||
          (pos[city + 1] - pos[city]) * truck[id].cost > curr)
        return false;
    }
    curr -= (pos[city + 1] - pos[city]) * truck[id].cost;
  }
  return true;
}
const long long high = 1000000000000000000LL;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> pos[i];
  for (int i = 1; i <= m; i++) {
    cin >> truck[i].start >> truck[i].finish >> truck[i].cost >>
        truck[i].refuel;
    ord[i] = i;
  }
  random_shuffle(ord + 1, ord + 1 + m);
  long long low = 0;
  for (int i = 1; i <= m; i++) {
    long long l = low + 1;
    long long r = high;
    long long fuel = 0;
    if (check(low, ord[i])) continue;
    while (l <= r) {
      long long mid = (l + r) / 2;
      if (check(mid, ord[i]) == true) {
        fuel = mid;
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    low = fuel;
  }
  cout << low;
}
