#include <bits/stdc++.h>
using namespace std;
struct kamion {
  int s, f, c, r;
} b[250005];
int n, m;
int a[405];
bool moze(kamion u, long long t) {
  long long gorivo = t;
  int ref = 0;
  for (int i = u.s; i < u.f; i++) {
    long long trosim = (a[i + 1] - a[i]) * 1ll * u.c;
    if (trosim > t) return false;
    if (gorivo - trosim < 0) {
      ref++;
      gorivo = t;
    }
    gorivo -= trosim;
  }
  return ref <= u.r;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cerr.tie(nullptr);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) cin >> b[i].s >> b[i].f >> b[i].c >> b[i].r;
  srand(reinterpret_cast<long long>(new int) ^ *(new int));
  for (int i = 0; i < m; i++) {
    int r = (rand() + (rand() << 10)) % (i + 1);
    swap(b[i], b[r]);
  }
  long long vbest = 0;
  for (int i = 0; i < m; i++) {
    if (!moze(b[i], vbest)) {
      long long lo = vbest + 1, hi = 1e18;
      while (lo <= hi) {
        long long mid = (lo + hi) >> 1;
        if (moze(b[i], mid)) {
          vbest = mid;
          hi = mid - 1;
        } else {
          lo = mid + 1;
        }
      }
    }
  }
  cout << vbest << '\n';
}
